Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access 7.1.259
  HXTT Cobol 5.0.258
  HXTT DBF 7.1.260
  HXTT Excel 6.1.262
  HXTT Json 1.0.230
  HXTT Paradox 7.1.258
  HXTT PDF 2.0.258
  HXTT Text(CSV) 7.1.258
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Word 1.1.258
  HXTT XML 4.0.259
Offshore Outsourcing
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
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT Text(CSV)
Insertion of binaryData
Rodolfo Martin
2005-03-22 00:00:00
Hi,
When inserting a byte[] with to bytes into the database it doesn't insert the byte[1] if it has 00 value (byte[0] != 0), whereas if the byte[0] has 00 value and byte[1] != 0 the two bytes are inserted.
I still have to test with longer byte[].

Is this the expected behaviour?

Thanks in advance.
Re:Insertion of binaryData
HXTT Support
2005-03-23 00:00:00
> it doesn't insert the byte[1] if it has 00 value (byte[0] != 0), whereas if the byte[0] has 00 value and byte[1] != 0 the two bytes are inserted.
Passed test with the below testTextNullvalue.java code. Your error isn't recured. Please let us know more about your issue.

import java.sql.*;
import java.util.Properties;

public class testTextNullvalue{
public static void main(String argv[]){
try{
Class.forName("com.hxtt.sql.text.TextDriver").newInstance();

String url="jdbc:Text:////textfiles";
// String url="jdbc:Text:/d:/textfiles";

Properties properties=new Properties();

final boolean changedFileExtension=true;//Whether change txt default file extension

properties.setProperty("fileExtension", "txt");

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

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

//plain text test
// String sql="CREATE TABLE if not exists testnull (abc varchar(20),content binary(2),_StuffedColumn char(2) default '\r\n');";
//csv test
String sql="CREATE TABLE if not exists testnull (abc varchar(20),content binary(2), _CSV_Separator char(1) default ',')";

stmt.executeUpdate(sql);

stmt.close();

sql = "insert into testnull (abc,content) values(?,?);";

PreparedStatement pstmt = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

byte[][] testvalues=new byte[][]{{'a','\0'},{'\0','\0'},{'\0','b'}};

for(int i=0;i<3;i++){
pstmt.setString(1, "name" + i);
pstmt.setBytes(2, testvalues[i]);
pstmt.executeUpdate();
}

for(int i=0;i<3;i++){
pstmt.setString(1, "name" + i);
pstmt.setString(2, new String(testvalues[i]));
pstmt.executeUpdate();
}


ResultSet rs = pstmt.executeQuery("select *,content+'' from testnull;");


ResultSetMetaData resultSetMetaData = rs.getMetaData();
int iNumCols = resultSetMetaData.getColumnCount();
for (int i = 1; i <= iNumCols; i++) {
System.out.println(resultSetMetaData.
getColumnLabel(i)
+ " " +
resultSetMetaData.getColumnTypeName(i));
}

rs.beforeFirst();
while (rs.next()) {
for (int i = 1; i <= iNumCols; i++) {
System.out.print(rs.getObject(i) + " ");
}
System.out.println();
}

rs.close();


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:Insertion of binaryData
Rodolfo Martin
2005-03-23 00:00:00
Hi,
I'm sorry my first question was incomplete. I have observed the commented behaviour when inserting a ResultSet from another oracle jdbc connection using Text suggested code:

String sql="insert into test ?;";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setObject(1,rs);
pstmt.executeUpdate();
pstmt.close();

Regards
Re:Re:Re:Insertion of binaryData
HXTT Support
2005-03-26 00:00:00
The latest package won't rtrim value or return null value for char type and binary type now.

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap