Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT DBF
error with receiving a lot of columns
Tverdokhlebov Mikhail
2006-06-09 00:55:28.0
selecting near 100 columns and some thousand rows,I've got an error: some columns of some rows were null in ResultSet,but they really had valid values in table.When reducing column count I've got valid values. Is it normal behaviour ? Ihaven't got any warnings.
Thank you!
Re:error with receiving a lot of columns
HXTT Support
2006-06-09 19:33:12.0
I created a dbf table with 200 columns and 100000 rows. It seems normal.



/* A simple test to recur an issue reported by Tverdokhlebov Mikhail */
import java.sql.*;
import java.util.Properties;

public class testDBFLotColumn1{
public static void main(String argv[]){
try{
Class.forName("com.hxtt.sql.dbf.DBFDriver");


String url="jdbc:dbf:////d:/test";

Properties properties=new Properties();

Connection con = DriverManager.getConnection(url,properties);

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String columnDefs="char0 char(20),int0 int";
final int columnCoupleCount=100;
for(int i=1;i columnDefs+=",char"+i+" char(20),int"+i+" int";
}
String sql="create table if not exists lotcolumns ("+columnDefs+");";
boolean initDataBaseFlag=stmt.executeUpdate(sql)>0;
stmt.close();

if(initDataBaseFlag){
String questions="?,?";
for(int i=1;i questions+=",?,?";
}
sql="insert into lotcolumns values("+questions+");";
PreparedStatement pstmt = con.prepareStatement(sql);
for(int i=0;i<100000;i++){
for(int j=0;j pstmt.setString(j*2+1,i+":"+j);
pstmt.setInt(j*2+2,j);
}
pstmt.executeUpdate();
}

pstmt.close();
}


sql="select recno(),* from lotcolumns";
PreparedStatement pstmt = con.prepareStatement(sql);
ResultSet rs=pstmt.executeQuery();
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int iNumCols = resultSetMetaData.getColumnCount();
for (int j = 1; j <= iNumCols; j++) {
System.out.println(resultSetMetaData.getColumnLabel(j)
+ " " + resultSetMetaData.getColumnTypeName(j)
+ " " + resultSetMetaData.getColumnType(j)
+ " " + resultSetMetaData.getPrecision(j)
+ " " + resultSetMetaData.getScale(j)
);
}
Object colval;
while (rs.next()) {
for (int j = 1; j <= iNumCols; j++) {
colval = rs.getObject(j);
if(colval==null){
throw new Exception("Found invalid value at row "+rs.getObject(1));
}
}
}
rs.close();
rs = null;
pstmt.close();

con.close();


}
catch( SQLException sqle )
{
do
{
System.out.println(sqle.getMessage());
System.out.println("Error Code:"+sqle.getErrorCode());
System.out.println("SQL State:"+sqle.getSQLState());
sqle.printStackTrace();
}while((sqle=sqle.getNextException())!=null);
}
catch( Exception e )
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}


Re:Re:error with receiving a lot of columns
HXTT Support
2006-06-09 19:35:05.0
Please check whether you're using a very old package.
Re:Re:Re:error with receiving a lot of columns
Tverdokhlebov Mikhail
2006-06-14 00:46:06.0
But problem really exists.Maybe,the reason is my SQL is complicated. I use such construction: select protocol.*,protinf.*,dcount.num_count,dcount.date_close from protocol join protinf join dcount where (protocol.contents=protinf.num) and (protocol.num_count=dcount.num_count) and (dcount.date_close= null )
The table protocol has 33 columns and near 100000 records,the table protinf has 2 columns and near 300000 rows, and table dcount has 68 columns and near 5000 rows.
When I use simply * in fields list, null values appear.
Excuse me for delay
Re:Re:Re:Re:error with receiving a lot of columns
Tverdokhlebov Mikhail
2006-06-14 01:00:52.0
I use jar of 08 june 06
Re:Re:Re:Re:Re:error with receiving a lot of columns
HXTT Support
2006-06-14 02:28:23.0
It seems normal still. Please download the latest package on June 13, 2006. You can try the testDBFLotColumn2 sample on your data, and that sample won't corrupte your data.

/* A simple test to recur an issue reported by Tverdokhlebov Mikhail */
import java.sql.*;
import java.util.Properties;

public class testDBFLotColumn2{
public static void main(String argv[]){
try{
Class.forName("com.hxtt.sql.dbf.DBFDriver");


String url="jdbc:dbf:////d:/test";

Properties properties=new Properties();

Connection con = DriverManager.getConnection(url,properties);

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String columnDefs="char0 char(10),int0 int";
int columnCoupleCount=15;
for(int i=1;i columnDefs+=",char"+i+" char(10),int"+i+" int";
}
String sql="create table if not exists protocol (contents int,num_count int, "+columnDefs+");";
boolean initDataBaseFlag=stmt.executeUpdate(sql)>0;

columnDefs="char0 char(10),int0 int";
columnCoupleCount=5;
for(int i=1;i columnDefs+=",char"+i+" char(10),int"+i+" int";
}
sql="create table if not exists protinf (num int, "+columnDefs+");";
stmt.executeUpdate(sql);

columnDefs="char0 char(10),int0 int";
columnCoupleCount=32;
for(int i=1;i columnDefs+=",char"+i+" char(10),int"+i+" int";
}
sql="create table if not exists dcount (num_count int,date_close boolean, "+columnDefs+");";
stmt.executeUpdate(sql);

stmt.close();

if(initDataBaseFlag){
String questions="?,?,?,?";
columnCoupleCount=15;
for(int i=1;i questions+=",?,?";
}
sql="insert into protocol values("+questions+");";
PreparedStatement pstmt = con.prepareStatement(sql);
for(int i=0;i<100000 ;i++){
pstmt.setInt(1,i);
pstmt.setInt(2,i);
for(int j=0;j pstmt.setString(j*2+3,i+":"+j);
pstmt.setInt(j*2+4,j);
}
pstmt.executeUpdate();
}

pstmt.close();

questions="?,?,?";
columnCoupleCount=5;
for(int i=1;i questions+=",?,?";
}
sql="insert into protinf values("+questions+");";
pstmt = con.prepareStatement(sql);
for(int i=0;i<300000;i++){
pstmt.setInt(1,i);
for(int j=0;j pstmt.setString(j*2+2,i+":"+j);
pstmt.setInt(j*2+3,j);
}
pstmt.executeUpdate();
}

pstmt.close();

questions="?,?,?,?";
columnCoupleCount=32;
for(int i=1;i questions+=",?,?";
}
sql="insert into dcount values("+questions+");";
pstmt = con.prepareStatement(sql);
for(int i=0;i<300000;i++){
pstmt.setInt(1,i);
pstmt.setObject(2,i%2==0?null:Boolean.TRUE);
for(int j=0;j pstmt.setString(j*2+3,i+":"+j);
pstmt.setInt(j*2+4,j);
}
pstmt.executeUpdate();
}

pstmt.close();
}


sql="select protocol.*,protinf.*,dcount.num_count,dcount.date_close from protocol join protinf join dcount where (protocol.contents=protinf.num) and (protocol.num_count=dcount.num_count) and (dcount.date_close= null ) ";
PreparedStatement pstmt = con.prepareStatement(sql);
ResultSet rs=pstmt.executeQuery();
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int iNumCols = resultSetMetaData.getColumnCount();
for (int j = 1; j <= iNumCols; j++) {
System.out.println(resultSetMetaData.getColumnLabel(j)
+ " " + resultSetMetaData.getColumnTypeName(j)
+ " " + resultSetMetaData.getColumnType(j)
+ " " + resultSetMetaData.getPrecision(j)
+ " " + resultSetMetaData.getScale(j)
);
}
Object colval;
int count=0;
while (rs.next()) {
count++;
for (int j = 1; j <= iNumCols; j++) {
colval = rs.getObject(j);
if(colval==null && j throw new Exception("Found invalid value at row "+rs.getObject(1));
}
}
}

System.out.println("count:"+count);

rs.close();
rs = null;
pstmt.close();

con.close();


}
catch( SQLException sqle )
{
do
{
System.out.println(sqle.getMessage());
System.out.println("Error Code:"+sqle.getErrorCode());
System.out.println("SQL State:"+sqle.getSQLState());
sqle.printStackTrace();
}while((sqle=sqle.getNextException())!=null);
}
catch( Exception e )
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
Re:Re:Re:Re:Re:Re:error with receiving a lot of columns
HXTT Support
2006-06-14 02:30:40.0
The
throw new Exception("Found invalid value at row "+rs.getObject(1));

should be:
throw new Exception("Found invalid value at row "+count);

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap