This is my code .. something that is wrong?
public void imprimirFactura(String codigo){
String sql="SELECT cliente.'c_razonsocial' AS cliente_c_razonsocial, ...."
conexion cc=new conexion();
Connection cn=cc.conexion();
ResultSet rs=null;
String NumeroFactura="";
String FechaVenta="";
String VentaIdVendedor="";
String VentaNombreCliente="";
String VentaRucCliente="";
String total = "";
PrinterMatrix printer = new PrinterMatrix();
Extenso e = new Extenso();
int filas =0;
e.setNumber(101.85);
try {
Statement st=cn.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
filas++;
NumeroFactura=codigo;
FechaVenta=rs.getString("venta_v_fechareg");
VentaIdVendedor=rs.getString("empleado_e_codigo");
VentaNombreCliente=rs.getString("cliente_c_nombre")+" "+rs.getString("cliente_c_apellido");
VentaRucCliente=rs.getString("cliente_c_ruc");
total = Numeros(rs.getString("venta_v_subtotal"));
}
} catch (SQLException ex) {
System.out.println("error 1");
}
//Definir el tamanho del papel para la impresion aca 25 lineas y 80 columnas
printer.setOutSize(60, 80);
//Imprimir * de la 2da linea a 25 en la columna 1;
printer.printCharAtLin(1, 25, 1, "*");
//Imprimir * 1ra linea de la columa de 1 a 80
printer.printCharAtCol(2, 1, 80, "=");//solo me imprime esta linea :(
//Imprimir Encabezado nombre del La EMpresa
printer.printTextWrap(3, 2, 30, 80, "FACTURA DE VENTA");
//printer.printTextWrap(linI, linE, colI, colE, null);
printer.printTextWrap(2, 3, 1, 22, "Num. Boleta : " + NumeroFactura);
printer.printTextWrap(2, 3, 25, 55, "Fecha de Emision: " + FechaVenta);
printer.printTextWrap(2, 3, 60, 80, "Hora: 12:22:51");
printer.printTextWrap(3, 3, 1, 80, "Vendedor. : "+VentaIdVendedor);
printer.printTextWrap(4, 4, 1, 80, "CLIENTE: " + VentaNombreCliente);
printer.printTextWrap(5, 5, 1, 80, "RUC/CI.: " + VentaRucCliente);
printer.printTextWrap(6, 6, 1, 80, "DIRECCION: " + "");
printer.printCharAtCol(7, 1, 80, "=");
printer.printTextWrap(7, 8, 1, 80, "Codigo Descripcion Cant. P P.Unit. P.Total");
printer.printCharAtCol(9, 1, 80, "-");
try {
Statement st=cn.createStatement();
//rs=st.executeQuery(sql);
int n=0;
while(rs.next()){
//printer.printTextWrap(9 + n, 10, 1, 80, rs.getString("producto_p_codigo")+"|"+rs.getString("producto_p_detalle")+"| "+rs.getString("detalle_venta_dv_cantidad")+"| "+Numeros(rs.getString("detalle_venta_dv_precio_unitario"))+"|"+ Numeros(rs.getString("detalle_venta_dv_importe")));
n++;
}
} catch (SQLException ex) {
System.out.println("error 2");
}
if(filas > 15){
printer.printCharAtCol(filas + 1, 1, 80, "=");
printer.printTextWrap(filas + 1, filas + 2, 1, 80, "TOTAL A PAGAR " + total);
printer.printCharAtCol(filas + 2, 1, 80, "=");
printer.printTextWrap(filas + 2, filas + 3, 1, 80, "Esta boleta no tiene valor fiscal, solo para uso interno.: + Descripciones........");
}else{
printer.printCharAtCol(25, 1, 80, "=");
printer.printTextWrap(26, 26, 1, 80, "TOTAL A PAGAR " + total);
printer.printCharAtCol(27, 1, 80, "=");
printer.printTextWrap(27, 28, 1, 80, "Esta boleta no tiene valor fiscal, solo para uso interno.: + Descripciones........");
}
printer.toFile("impresion.txt");
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream("impresion.txt");
} catch (FileNotFoundException ex) {
ex.printStackTrace();
System.out.println("error inputStream");
}
if (inputStream == null) {
System.out.println("inputStream null");
return;
}
DocFlavor docFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc document = new SimpleDoc(inputStream, docFormat, null);
PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
if (defaultPrintService != null) {
DocPrintJob printJob = defaultPrintService.createPrintJob();
try {
printJob.print(document, attributeSet);
System.out.println("imprimiendo");
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("hay error --");
}
} else {
System.err.println("No existen impresoras instaladas");
}
//inputStream.close();
}