Saboor880 9

Thanx James. I flushed out and closed the streams and the problem is solved.

Saboor880 9

I have written a code to generate bar codes and saved them to a pdf file . The code executes successfylly but the PDF file does not open saying giving an error whome picture I am uploading. Please see my code and Picture with the error.

barcodeError.PNG

 public void createPDF(String pdfFileName,String myString) throws FileNotFoundException{
        Document doc = new Document() ;
        PdfWriter docwriter = null;

        try{
            docwriter = PdfWriter.getInstance(doc, new FileOutputStream("C:\\Users\\hp430\\Desktop\\barcodes\\"+pdfFileName));
            doc.addAuthor("Saboor Siddique");
            doc.addCreationDate();
            doc.addProducer();
            doc.addCreator("SunSoftTechnologies");
            doc.addTitle("Barcode Test");
            doc.setPageSize(PageSize.LETTER);
            doc.open();

            PdfContentByte cb= docwriter.getDirectContent();

            Barcode128 code128 = new Barcode128();
            code128.setCode(myString.trim());
            code128.setCodeType(Barcode128.CODE128);
            code128.setBarHeight(5f);
            code128.setX(0.1f);

            Image code128Image = code128.createImageWithBarcode(cb, null, null);
            code128Image.setAbsolutePosition(10, 700);
            code128Image.scalePercent(125);
            doc.add(code128Image);

        }
        catch(DocumentException dex){
            System.out.println(dex);
        }
    }

Saboor880 9

James brother actually I wrote the program in such a way that , if database exists , then it connects the database other wise it creates database and then connects with it. I explicitly wants that the database should be created in the C Drive, whether it is local host or server machine. Because I also have a Backup and Restore feature in my software, which allows user to take Backup or restore the Data on a single click of button. The program works perfectly with my local host. But it only create problem when I run derby on server machine. And I run the derby by the command which I posted in first post. Derby server also starts successfully but , when I run my program , then the above mentioned exception occurs.

And in your previous reply you said that " may be its version incompatibility". Can you elaborate what type of version incompatability can it be? Because I am using same version of jdk and Derby on my client and server machine.
Thanks in advance.

rproffitt commented: If you are running on old Java versions, few will be able to answer when things get weird. +0

Saboor880 9

Thanx James Cherill. James cherill I have faced a new problem, I am posting that problem here. I will be thank full to you if you guide me on that.

Now I am making my pos software client - server based software. I am using java derby as the database. On the local host I am running the program successfully. But on the remote server I face an exception. First I tell you, how I am connecting to the remote server below:

I connect my laptop to my pc through LAN Cable. I am using my laptop as client and my desktop PC as Server. On my Server I run the following command to start the Derby Server:

C:\Program Files (x86)\Java\jdk1.7.0_79\db\lib> java -jar derbyrun.jar start server

Above mentioned command starts the derby server on my desktop computer.

I am using following driver and connection string on my client laptop:

// code for driver
String dbdriver = "org.apache.derby.jdbc.ClientDriver";
        Class.forName(dbdriver).newInstance();

// connection string where "192.168.10.125" is ip address of my server PC and "139" is port number of   //my server PC
 con = DriverManager.getConnection("jdbc:derby://192.168.10.125:139/C:\\QuintexDB; create = true"); 

When I run the program, following Exception Occurres:

"java.sql.SQLNonTransientConnectionException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 5 bytes. The connection has been terminated."

I am searching this problem on internet since last night but all in vane. I will be thank ful to you if you can guide me on this.

rproffitt commented: When you have an issue solved, yes, mark it solved. New issue? New post please. +15

Saboor880 9

Thank you very much James. I understood very well.