| Welcome Guest |
![]](/skins/invision/forum_images/hide_off.gif) |
|
|
|
| Welcome to the Mirtheil Software home page. On this page you'll find information regarding the products and services Mirtheil Software offers. Enjoy your stay. |
|
| DataXtraction 1.5.86 Released |
| Posted: mirtheil @ 25 April 2013 8:37am | This release fixes an issue where the export would stop if a table did not exist when exporting all tables. An updated executable can be downloaded here or a full install can be downloaded here.
| | Comments: 0 | Views: 187 | Add/View Comments | |
| DataXtraction 1.5.85 Released |
| Posted: mirtheil @ 26 September 2012 7:41am | This release fixes an issue where field names were always being included in the exported file. An updated executable can be downloaded here or a full install can be downloaded here.
| | Comments: 0 | Views: 1114 | Add/View Comments | |
| Insert LongVarChar using JDBC and PSQL |
| Posted: mirtheil @ 07 September 2012 11:46am | Recently, I was asked if the Pervasive PSQL JDBC driver could read and write to a LongVarChar field. In my research, I found that it was possible and fairly easy using the setAsciiStreamfunction. First, make a connection to the database, for example: [code]String url = "jdbc:pervasive://localhost:1583/DEMODATA"; Connection conn; conn = DriverManager.getConnection(url);[/code] Once the connection is made, a statement needs to be prepared: [code]PreparedStatement ps = conn.prepareStatement("INSERT INTO Article (Subject, Body) VALUES (?,?)");[/code] Then set the values for each field: [code]String subject = "Test of setAsciiStream() methods"; ps.setString(1, subject); FileInputStream fis = null; File file = new File("FileTest.txt"); fis = new FileInputStream(file); ps.setAsciiStream(2, fis, (int) file.length());[/code] Now, execute the Update: [code]int count = ps.executeUpdate();[/code] The contents of the FileTest.txt is now stored in the PSQL database. To read a LongVarChar field, execute a SELECT statement: [code]Statement sta = conn.createStatement(); ResultSet res = sta.executeQuery("SELECT * FROM Article" +" WHERE Subject = '"+subject+"'"); res.next(); System.out.println("The inserted record: "); System.out.println(" ID = "+res.getInt("ID")); System.out.println(" Subject = "+res.getString("Subject")); [/code] The LongVarChar field can be saved to a text file using the getAsciiStream function: [code]stream = res.getAsciiStream("body"); File f = new File("out" + res.getInt("ID") + ".txt"); OutputStream out=new FileOutputStream(f); byte buf[]=new byte[1024]; int len; while((len=stream.read(buf))>0) out.write(buf,0,len); out.close(); System.out.println(" Body saved as file: out" + res.getInt("ID") + ".txt");[/code]
| | Comments: 0 | Views: 1225 | Add/View Comments | |
|
|
| Top 3 Recent Posts |
![]](/skins/invision/forum_images/hide_off.gif) |
|
|