Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Ascii character 129 for newline in the text file

843859Apr 10 2007 — edited Apr 10 2007
Hi there,
I have java program that makes JDBC connection and reads through a table, write a column in text file, after each column puts delimiter "|"and after each row prints in the next line.
This is the code below.
public void queryRecords() {
         Statement stmt           = null;
        ResultSet rset           = null;
           
        try {
              stmt = con.createStatement();
              int numRows = 0;
            File file           = new File("/tmp/temp.txt");
            FileWriter writer   = new FileWriter(file, false);
            BufferedWriter pw      = new BufferedWriter(writer);
            
            rset = stmt.executeQuery("SELECT * FROM mytable");
            ResultSetMetaData rsmd = rset.getMetaData();
            int colCount = rsmd.getColumnCount();
            
            while (rset.next()) {
                for (int i = 1;i <= colCount; i++) {
                    String st = rsmd.getColumnTypeName(i);
                    if (st.equals("DATE")) {
                        Date d1 = rset.getTimestamp(i);
                        pw.write(d1 + "|");
                    } else {
                        Object o1 = rset.getObject(i);
                        
                        if (o1 != null) {
                            pw.write(o1 + DELIM);
                        } else {
                            pw.write(DELIM);
                            
                        }
                        
                    }
                }
                pw.newLine();
                 }
            pw.close();
             rset.close();
             stmt.close();
When i open this Temp.txt file in notepad i see ascii character 129 (rectangular box) instead of the new line. But when i print the file i have each row in a separate line.

Why could this be happening??

Please help...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2007
Added on Apr 10 2007
13 comments
258 views