Hi,

I am trying to create / access to OpenOffice 2.0 Base
from a java program. Here is my program for creating a
file. It seems like successful because after that I
can try to access the data from another java program.

However, when I tried to open the file using
OpenOffice 2.0 Base, there is an error "The connection
to the datasource could not be established. An unknown
error is occured. Driver is probably defective".

I tried the other way round. I create a file using
OpenOffice 2.0 Base. Then I tried to access from a
java program for simple query. The error message said
"the tabel could not be found".

Can anybody help me to find out the cause of the
error?

Here is my program.

import java.sql.*;
import java.util.*;
import javax.sql.*;
import org.hsqldb.*;

public class CreateTable
{
  public static void main(String[] args)
  {

    try
    {
      Class.forName("org.hsqldb.jdbcDriver");
    }
    catch(ClassNotFoundException fnfex)
    {
      System.out.println("Class Not Found");
      System.exit(1);
    }

    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;

    try
    {

      con =
       
DriverManager.getConnection("jdbc:hsqldb:file:Test103","sa","");

      StringBuffer qry = new StringBuffer();
      qry.append(" create table Table1 ");
      qry.append(" (serial int primary key , ");
      qry.append("  fa char(10), fb char(10) ) ");
      stmt = con.prepareStatement(qry.toString());

      stmt.executeUpdate();

      qry = new StringBuffer();
      qry.append(" insert into Table1 ");
      qry.append(" values (1, 'abc','def') ");

      stmt = con.prepareStatement(qry.toString());
      stmt.executeUpdate();

      stmt =con.prepareStatement("SHUTDOWN");
      stmt.executeUpdate();

      con.close();
    }
    catch(SQLException sqlex)
    {
 
    }
  }
}







                
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to