Hi,
Bug#1:
1- I created a new database and a new table in there
2- Just after step 1, I tried to insert some records in the table, but it was not successful. But when I executed the program again where the database was already created at the first time, it was successful.
So, the problem is that, the driver is not capable to do both jobs consecutively.
Note: I uses Java 5.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import junit.framework.TestCase;
/**
* @author barmak
*
*/
public class MSAccessTest extends TestCase {
private static String CATALOG_PATH = "c:/temp/testaccess";
private static String DATABASE_NAME = "Database1";
private static String TABLE_NAME = "Table1";
private Connection connection;
public MSAccessTest(String name) {
super(name);
}
/**
* @throws java.lang.Exception
*/
protected void setUp() throws Exception {
String lUrl = "jdbc:access:///"+CATALOG_PATH;
Properties prop=new Properties();
prop.setProperty("versionNumber","JET4");//default
prop.setProperty("charSet","Cp1252");//correct
DriverManager.registerDriver(new com.hxtt.sql.access.AccessDriver());
connection = DriverManager.getConnection(lUrl, prop);
}
/**
* @throws java.lang.Exception
*/
protected void tearDown() throws Exception {
}
public void test1() throws Exception{
//1 create database
Statement statement = connection.createStatement();
statement.execute("create database if not exists "+DATABASE_NAME+"");
statement.execute("create table if not exists "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha varchar(25))");
statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello1')");
statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello2')");
statement.close();
connection.close();
}
}
Question #1: Is it possible to create a Catalog in zip form from java.
Best regards, Barmak Heidarasadi
|
A for now workaround:
When 2 tables are created, it works fine:
Statement statement = connection.createStatement();
statement.execute("create database if not exists "+DATABASE_NAME+"");
statement.execute("create table "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha varchar(25))");
statement.execute("create table if not exists "+DATABASE_NAME+"."+"BUG_WORKAROUND_TABLE"+"(TAlpha varchar(25))");
statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello1')");
statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello2')");
statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello3')");
statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello4')");
statement.execute("drop table "+DATABASE_NAME+"."+"BUG_WORKAROUND_TABLE");
|
>statement.execute("create database if not exists "+DATABASE_NAME+"");
>statement.execute("create table if not exists "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha varchar(25))");
>statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello1')");
>statement.executeUpdate("insert into "+DATABASE_NAME+"."+TABLE_NAME+"(TAlpha) values('Hello2')");
Failied to recur your issue. What's your exception message?
The simplest solution:
statement.execute("create database if not exists "+DATABASE_NAME+"");
con.setCatalog(DATABASE_NAME+".mdb");
statement.execute("create table if not exists "+TABLE_NAME+"(TAlpha varchar(25))");
...
|
There is no exception at all, it just does not write the records into the table.
It creates database and tables successfully, but cannot write into the table as the next step (without reporting any exception).
Anyway I managed to find a workaround, (I already posted it), may be a clue for you.
|
Recurred and fixed. Thanks. We will release the latest package in 24 hours.
|