Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v5.0
  HXTT DBF v7.1
  HXTT Excel v6.1
  HXTT Json v1.0
  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 ACCESS
How to create a new database and create a table in it ?
Scott Harger
2005-07-18 00:00:00
Problem creating new databases and updating existing mdb file.

Can someone provide example code as to how to create a new database and create a table in it ? Ultimately I want to end up with an mdb file that contains four tables.

I can select tables out of an existing mdb fine but I am unable to create a new database and create tables in it. For example:

Class.forName("com.hxtt.sql.access.AccessDriver");
String url = "jdbc:Access:/c:/tmp/data";
Connection con = DriverManager.getConnection(url, new Properties());
Statement stmt = con.createStatement();
stmt.execute("create schema mydb");
stmt.execute("create table if not exists mydb.mytable (name varchar(80), address varchar(255))");

Fails with

[java] java.sql.SQLException: Failed to load database mydb! For more information, please use SQLException.getNextException().
[java] at com.hxtt.global.SQLState.SQLException(Unknown Source)
<...>
[java] at com.contentdiscovery.cds.apps.TestAccess.main(TestAccess.java:39)

[java] java.io.FileNotFoundException: C:\tmp\data\mydb.MDB (The system cannot find the file specified)
[java] java.sql.SQLException: java.io.FileNotFoundException: C:\tmp\data\mydb.MDB (The system cannot find the file specified)

Also, when I open an existing mdb database and perform updates on the table they do not take effect, even though the update was committed and the number of rows effected as indicated by the return value to executeUpdate() indicates that a row was updated. A subsequent select of the table shows that the update did not take effect.
Re:Engineer
HXTT Support
2005-07-18 00:00:00
> Can someone provide example code as to how to create a new database and create a table in it ? Ultimately I want to end up with an mdb file that contains four tables.
Our programmers are writing code for CREATE TABLE and CREATE DATABASE, but that function hasn't been provided now.

>when I open an existing mdb database and perform updates on the table they do not take effect
INSERT/UPDATE/DELETE should work normal. Just let us see your sql. Thanks.
update problem
Scott Harger
2005-07-18 00:00:00
The following code fragment doesn't work.

Class.forName("com.hxtt.sql.access.AccessDriver");
String url = "jdbc:Access:/c:/tmp/mydata.mdb";
Connection con = DriverManager.getConnection(url, new Properties());
ResultSet rs = con.createStatement().
executeQuery("select Title from export where id = 2");
while(rs.next()) {
String title = rs.getString(1);
System.out.println("Title = " + title);
}
int count = con.createStatement().
executeUpdate("update export set Title = 'New Title' where id = 2");
System.out.println("Updated " + count + " rows.");
rs = con.createStatement().
executeQuery("select Title from export where id = 2");
while(rs.next()) {
String title = rs.getString(1);
System.out.println("Title = " + title);
}
con.close();

This is the output:

Title = Rx_11Mbps_SNR20_Channel1_CarrierOffset0_ClockOffset40
Updated 1 rows.
Title = Rx_11Mbps_SNR20_Channel1_CarrierOffset0_ClockOffset40
Re:Re:Re:Engineer
HXTT Support
2005-07-18 00:00:00
Passed test with the below output:
Title = Rx_11Mbps_SNR20_Channel1_CarrierOffset0_ClockOffset40

Updated 1 rows.

Title = New Title

If possible, please email us your mydata.mdb or email a download url to webmaster@hxtt.com . Thanks.
Re:Re:Re:Engineer
HXTT Support
2005-07-18 00:00:00
Passed test with the below output:
Title = Rx_11Mbps_SNR20_Channel1_CarrierOffset0_ClockOffset40

Updated 1 rows.

Title = New Title

If possible, please email us your mydata.mdb or email a download url to webmaster@hxtt.com . Thanks.
Re:Re:Re:Re:Re:How to create a new database and create a table in it ?
HXTT Support
2006-06-29 06:26:55
A complementary explanation:
Since 2005-09-12, HXTT Access v1.0 supports REATE TABLE and CREATE INDEX.
HXTT Access v1.0.43 supports CREATE DATABASE.
HXTT Access v1.0.62 supports DROP TABLE.

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