Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v6.1
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
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 DBF
NullPointerException on INSERT into table with index on .Not.Deleted()
Shackleford
2020-03-02 08:24:32.0
Hello,

We're having a problem with INSERTs into tables that have an index on ".Not.Deleted()" when the transaction isolation is set to "read committed".

A small sample to recreate:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class DBFInsert
{
static final String JDBC_DRIVER = "com.hxtt.sql.dbf.DBFDriver";
static final String INSERT = "insert into so.dbo.ASSIGNED (cassigned_key, cdesc, lactive) values (?, ?, ?)";
static final Object[] VALUES = new Object[] { "test", "test", 1 };

public static void main(String[] args) throws Exception
{
if (args.length != 1)
{
System.err.println("Usage: DBFInsert url");
System.exit(-1);
}

String url = args[0];

Class.forName(JDBC_DRIVER);

Connection connection = DriverManager.getConnection(url, "", "");

System.out.println("Executing sql '" + INSERT + "'");

// This is needed to trigger the NullPointerException
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

try (PreparedStatement ps = connection.prepareStatement(INSERT))
{
ps.setString(1, (String)VALUES[0]);
ps.setString(2, (String)VALUES[1]);
ps.setInt(3, ((Number)VALUES[2]).intValue());

ps.executeUpdate();
}

connection.close();

System.out.println("Done");
}
}

Output when running:
> java -cp .;C:\servoy\application_server\drivers\DBF_JDBC42.jar DBFInsert jdbc:dbf:////C:\tmp\data\so

Executing sql 'insert into so.dbo.ASSIGNED (cassigned_key, cdesc, lactive) values (?, ?, ?)'
Exception in thread "main" java.sql.SQLException: java.lang.NullPointerException
at com.hxtt.sql.dx.a(Unknown Source)
at com.hxtt.sql.g.a(Unknown Source)
at com.hxtt.sql.fy.a(Unknown Source)
at com.hxtt.sql.dbf.DBFIndex.a(Unknown Source)
at com.hxtt.sql.dbf.DBFIndex.if(Unknown Source)
at com.hxtt.sql.dbf.j.a(Unknown Source)
at com.hxtt.sql.da.do(Unknown Source)
at com.hxtt.sql.fl.for(Unknown Source)
at com.hxtt.sql.d6.a(Unknown Source)
at com.hxtt.sql.b1.a(Unknown Source)
at com.hxtt.sql.b1.if(Unknown Source)
at com.hxtt.sql.b1.a(Unknown Source)
at com.hxtt.sql.aq.a(Unknown Source)
at com.hxtt.sql.aq.a(Unknown Source)
at com.hxtt.sql.d7.executeUpdate(Unknown Source)
at DBFInsert.main(DBFInsert.java:36)


Re:NullPointerException on INSERT into table with index on .Not.Deleted()
HXTT Support
2020-03-04 19:37:07.0
Passed test with v7.0.074. Maybe you're using an older package.



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;

public class DBFInsert {

static final String JDBC_DRIVER = "com.hxtt.sql.dbf.DBFDriver";
static final String INSERT = "insert into so.dbo.ASSIGNED (cassigned_key, cdesc, lactive) values (?, ?, ?)";
static final Object[] VALUES = new Object[]{"test", "test", 1};

public static void main(String[] args) throws Exception {
boolean needInitDatabaseFlag=false;
if (args.length == 0) {
args=new String[]{"jdbc:dbf:/d:/test/dbf/issue4?versionNumber=DB2K"};//DB2K to support cassigned_key in free table
needInitDatabaseFlag=true;
}

if (args.length != 1) {
System.err.println("Usage: DBFInsert url");
System.exit(-1);
}

String url = args[0];

Class.forName(JDBC_DRIVER);

Connection connection = DriverManager.getConnection(url, "", "");

if(needInitDatabaseFlag){
Statement s=connection.createStatement();
s.executeUpdate("create catalog if not exists so;");
s.executeUpdate("create table if not exists so.ASSIGNED (cassigned_key varchar(12),cdesc varchar(12),lactive int);");
s.executeUpdate("create index if not exists demotest of ASSIGNED.cdx on so.ASSIGNED ( cassigned_key for not deleted());");
}

System.out.println("Executing sql '" + INSERT + "'");

// This is needed to trigger the NullPointerException
connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

try (PreparedStatement ps = connection.prepareStatement(INSERT)) {
ps.setString(1, (String) VALUES[0]);
ps.setString(2, (String) VALUES[1]);
ps.setInt(3, ((Number) VALUES[2]).intValue());

ps.executeUpdate();
}

connection.close();

System.out.println("Done");
}
}
Re:Re:NullPointerException on INSERT into table with index on .Not.Deleted()
Shackleford
2020-03-05 08:04:35.0
Hello.

You're correct. I was using 7.0.014 and didn't realize this was an older driver. The insert works correctly using 7.0.074. I should have realized I was using an older version.

Thanks for your help.

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 | Sitemap