HXTT Text(CSV)
Insertion of binaryData
Rodolfo Martin
2005-03-22 00:00:00.0
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.0
> 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.0
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.0
The latest package won't rtrim value or return null value for char type and binary type now.


Google