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

Forgot password? | Register

Site Navigation

   
Welcome
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:  2738 | 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:  2961 | 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:  3345 | Add/View Comments

   
Top 3 Recent Posts ] ]
View Last Post Pervasive SQL2000 SP1
Last Post By: mirtheil
Forum: Btrieve

Posted: Yesterday at: 7:07am

View Last Post dbadd.exe
Last Post By: rikkard
Forum: SQL/ODBC

Posted: 04 November 2013 at: 12:54am

View Last Post DataXtraction 1.5.86 Released
Last Post By: mirtheil
Forum: Website News

Posted: 25 April 2013 at: 8:37am



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