Welcome Guest ] ]
Auto Login
Add me to Active Users list
Yes  No

Forgot password? | Register

Site Navigation

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:  3077 | 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:  3159 | 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+"'");
System.out.println("The inserted record: ");
System.out.println("   ID = "+res.getInt("ID"));
System.out.println("   Subject = "+res.getString("Subject"));
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;
System.out.println("   Body saved as file: out" + res.getInt("ID") + ".txt");[/code]

Comments:  0 | Views:  3523 | Add/View Comments

Top 3 Recent Posts ] ]
View Last Post Btrieve locks file
Last Post By: mirtheil
Forum: Btrieve

Posted: 28 September 2014 at: 3:26pm

View Last Post Pervasive SQL2000 SP1
Last Post By: mirtheil
Forum: Btrieve

Posted: 19 September 2014 at: 8:40am

View Last Post dbadd.exe
Last Post By: rikkard

Posted: 04 November 2013 at: 12:54am

Content Copyright © 2000 - 2014 Mirtheil Software.Powered by SOOP Portal Raven 1.0