Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v2.1
  HXTT DBF v5.2
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
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
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan 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.0
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.0
> 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.0
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.0
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.0
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.0
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
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap