If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > run in my PC: Type 1 db driver Access / java[SE1.6] Desktop Applications, what I need

Reply
 
LinkBack Thread Tools Display Modes
  #16 (permalink)  
Old 11-19-09, 06:41
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
Although I get below, how to view in Access 2003 THE DATA in WINES(I use DSN)? I tried but do not recreated/modified after addition...

C:\Users\User\Documents\TextBooksDataFiles\The Web Warrior Guide to Web Database Technologi
es, 1st Edition\Practice\ch6>java ExampleOfDatabaseLoad data1
CREATE TABLE WINES(NAME_WINE CHAR(20), COLOR_WINE CHAR(10), COST CURRENCY, ON_HAND INTEGER)

SQL statement:INSERT INTO WINES VALUES ('White Zinfandel I', 'Purple', 3.92, 100)
Record Added.
SQL statement:INSERT INTO WINES VALUES ('Blush Zinfandel','Orange', 5.89, 25)
Record Added.
SQL statement:INSERT INTO WINES VALUES ('Chardonnay', 'Red', 18.22, 30)
Record Added.
SQL statement:INSERT INTO WINES VALUES ('Champagne', 'Pink', 25.82, 15)
Record Added.
SQL statement:INSERT INTO WINES VALUES ('kChampagne2', 'Pink2', 25.22, 152)
Record Added.

C:\Users\User\Documents\TextBooksDataFiles\The Web Warrior Guide to Web Database Technologi
es, 1st Edition\Practice\ch6>
Reply With Quote
  #17 (permalink)  
Old 11-19-09, 06:42
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
I must open in Access DSN or database file ?
Reply With Quote
  #18 (permalink)  
Old 11-19-09, 07:03
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
Quote:
Originally Posted by lse123 View Post
I must open in Access DSN or database file ?
If you have Office Access program, you can open the database with it (DSN or not) and see here if a "WINES" table exists with all records you created.
If not, you shoud add a "SELECT * from WINES" query in your program and see if you get back what you put.

I suspect you don't understand clearly the way things work here. Java JDBC is a general API to deal with databases. .mdb files can be opened, viewed and modified with Access itself, ODBC, and even SQLServer, and *not only* with the application which created the tables and data. All these are databases engines which can manage .mdb files (schema and data), and Java JDBC must connect to a database engine (ODBC here), not only open a file. But the file itself can be used later with any engine you wish. So you can design a database with Access software, modify it with ODBC (and Java maybe), and reopen it later with Access. Or the contrary.
HTH
Laurent

Last edited by Pyrophorus; 11-19-09 at 07:08.
Reply With Quote
  #19 (permalink)  
Old 11-19-09, 09:08
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
I suspect THAT IN MY CASE ONLY select statement works, insert statement doesn't works since when open with Access the mdb file non such records seen, and also when execute java programs to view records like below appears only old TABLE(old 3 records only) unmodified...well???

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection
("jdbcdbc:RedWines");
Statement sttmnt = conn.createStatement (
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY );

ResultSet rs=sttmnt.executeQuery("SELECT * FROM WINES");
// Retrieve records from WINES

int typeResultSet = rs.getType();
System.out.println("Type result set: " + typeResultSet);

rs.afterLast(); // Move pointer after the last record

while (rs.previous()) { // Backwards through result set
String name = rs.getString("NAME_WINE");
String color = rs.getString("COLOR_WINE");
int on_hand = rs.getInt("ON_HAND");
System.out.println(name + " " + on_hand + " " + color);
}

rs.absolute(3); // Move to record number 3
System.out.println("The name in the 5th record is " +
rs.getString("NAME_WINE"));

rs.relative(-1); // Move backwards one record
System.out.println("The name in the 2nd record is " +
rs.getString("NAME_WINE"));
rs.close();
sttmnt.close ();
conn.close();
Reply With Quote
  #20 (permalink)  
Old 11-19-09, 09:40
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
I think you should check privileges in your database: looks like you have only read privilege on it (ResultSet type could help too: is it updatable ?).
Feel free to post too Access forum for this. I'm not an Access expert and can't help much here.

Laurent
Reply With Quote
  #21 (permalink)  
Old 11-19-09, 10:16
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
even appear
SQL statement:INSERT INTO WINES VALUES ('kChampagne2', 'Pink2', 25.22, 152)
Record Added.

and when privileges for insert no exist [no insert]
so no written data ?
Reply With Quote
  #22 (permalink)  
Old 11-19-09, 10:32
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
may run same time DSN from all kind of databases eg MySQL or Access interchangeably without any setting to setup for the change?
Reply With Quote
  #23 (permalink)  
Old 11-19-09, 11:15
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
Quote:
Originally Posted by lse123 View Post
may run same time DSN from all kind of databases eg MySQL or Access interchangeably without any setting to setup for the change?
You have only to select a MySQL driver in your Class.forName(""); instruction. You'll find the java library on Sun's site or MySQL site. However, SQL syntax may vary slightly from one database to another.

Quote:
Originally Posted by lse123 View Post
even appear
SQL statement:INSERT INTO WINES VALUES ('kChampagne2', 'Pink2', 25.22, 152)
Record Added.

and when privileges for insert no exist [no insert]
so no written data ?
Yes. Try to execute a commit(); on your Connection Object just in case it is not in autoCommit mode.

Laurent
Reply With Quote
  #24 (permalink)  
Old 11-23-09, 01:17
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
HOW I turn Access to autoCommit mode ?
DSN vs Actual DB: MAY I MODIFIED ONLY RESULT SET AND NON ACTUAL DATABASE? WELL autoCommit COMMIT TO DB ? HOW INSERT WITH CHANGES TO ACTUAL DATABASE?
Reply With Quote
  #25 (permalink)  
Old 11-23-09, 04:59
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
Try to be precise here: commit() and setAutoCommit() are Connection object methods and have little to do with Access. Look at the javadoc for this class.

In SQL, you must commit your changes explicitly. With JDBC, you can use autoCommit mode (a Connection object mode): then a commit is silently sent to the database after every update call.

If you don't see any change in your Access file, maybe it's just because no commit is done in your program. You can add one of the two:
conn.setAutocommit(true); // at the beginning
conn.commit(); // before quitting, when all's done.

Laurent
Reply With Quote
  #26 (permalink)  
Old 11-23-09, 11:05
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
well where to look and find this database table ?

The problem must be with the driver or DSN, Seems that I query other Access table ? How open a DSN in Access?

I proceed and make a script: create table > insert data from a file.txt > appear data [ExampleOfDatabaseLoadappearonscreen.java], and data appeared success, well where to look and find this database table ?

I use Access 2003 & MySQL 5.1 may mess up ? I Access I do not see and change in Table ...well

see screen shot and ExampleOfDatabaseLoadappearonscreen.txt(.java) ...
Attached Thumbnails
run in my PC: Type 1 db driver Access / java[SE1.6] Desktop Applications, what I need-privileges-access2003-2.jpg  
Attached Files
File Type: txt data1.txt (289 Bytes, 39 views)
File Type: txt ExampleOfDatabaseLoadappearonscreen.txt (3.2 KB, 43 views)
Reply With Quote
  #27 (permalink)  
Old 11-23-09, 11:10
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
also in the database file's folder created some files ODBC, ODBC1, ODBC2, ... ODBC8.
(RIGHT CLICK: PROPERTIES->Microsoft Office Access Application (.mdb))

I THINK THERE ARE NULL
Reply With Quote
  #28 (permalink)  
Old 11-23-09, 13:10
Pyrophorus Pyrophorus is offline
Registered User
 
Join Date: Aug 2009
Posts: 68
Well, did you tried to open these ODBC files with Access ?
By the way, I think your DSN doesn't point to the file you try to open later with Access. Most probably you write successfully in another .mdb file.

If you I would test with the alternative syntax, specifying the file path directly in the connection string. This way you could make sure you open later the right file.
(BTW, you can't open a DSN with Access. DSN are only definitions: they specify a file and a driver to manage it, exactly the same informations you have in the full syntax)

Laurent
Reply With Quote
  #29 (permalink)  
Old 11-23-09, 14:23
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
Well, did you tried to open these ODBC files with Access ?
yes appear access but no tables no queries no nothing ...

DRIVER is already come installed with Access , samely bridge come with java already , so no needed any driver installation, just make a DSN ?

UPON modify TABLE Contents Access 2003 need refresh to show the contents(this only if same time I view table's contents). correct ?
Reply With Quote
  #30 (permalink)  
Old 11-23-09, 14:24
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 130
I am going now try other way...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On