2016-01-12 23 views
0

我不能分辨这句法:错误syntac ZPL字符串转换成字节假脱机打印

printerConnection.write(configLabel = "^FO80,160 ^BY1,2.0,180^BCN,180,Y,N,N^FD" + nor + "^FS".getBytes());//error in here 

printerConnection.write(configLabel = "^FO250,400 ^A0,38,38^FD" + name + "^FS" .getBytes());//error in here 

printerConnection.write(configLabel = "^XZ".getBytes()) 


//its Query for input to syntax ZPL 

sql1= "SELECT norm as a1, " 
+ "name as a " 
+ "from xytable" 
+ "where nor ="+noRParameter+" "; 
java.sql.Statement stmt=koneksi.createStatement(); 
java.sql.ResultSet rslt=stmt.executeQuery(sql1); 
while(rslt.next()){ 
String nor = rslt.getString("nor"); 
String name = rslt.getString("name");} 

我在剧本ZPL遇到错误。这是字节,但我有字符串中的数据?你可以帮我吗?以前感谢:)

回答

0

你只对最后一个字符串执行getBytes()方法。
您需要类似的东西:

printerConnection.write(
    // Note the added parents around the String you want to execute getBytes() on. 
    configLabel = ("^FO80,160 ^BY1,2.0,180^BCN,180,Y,N,N^FD" + nor + "^FS").getBytes() 
);