File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Jdbc" Watch "Jdbc" New topic
Author

Jdbc

Curtis Bridges
Greenhorn

Joined: Jul 26, 2007
Posts: 9
I need some help. I'm trying to connect to a database I created in MS ACCESS the file name is db challenge.mdb
would somebody heip me out ? Please.
I'm getting 3 errors on lines 44,47,52 saying cannot find symbol variable rowSet
1 error on line 26 that say's cannot find symbol method JdbcRowSetImpl()
1 error on line 28 that say's cannot find symbol method setUserName(java.lang.String)


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

First of all, the variable is called rowset, not rowSet

Second of all, don't do it this way! Whenever using JDBC, you should do the following:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Curtis Bridges
Greenhorn

Joined: Jul 26, 2007
Posts: 9
Thank you, Rob,
I changed rowset as suggested. Inserted your code but am still getting errors on # 29
cannot find symbol variable DriverManager,cannot find symbol class Connection
# 31 cannot find symbol class Statement
# 35 cannot find symbol variable ResultSet
# 39 and # 42 cannot find symbol variable rs
Any ideas? New code below.


Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

I need some help. I'm trying to connect to a database I created in MS ACCESS the file name is db challenge.mdb
would somebody heip me out ? Please.


If you are trying to connect to a access database named challenge, then why are you using the mysql driver and connecting to books?



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
You can make it easier for yourself by using

instead of

That way you'll cover the ResultSet, Statement and other related classes as well.


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

The errors about DriverManager, Statement and ResultSet were because you didn't import them; Ulf's suggestion should solve that.

As for the rs part, you forgot it in your code:
Curtis Bridges
Greenhorn

Joined: Jul 26, 2007
Posts: 9
/*Thanks guys. We have this down to 1 error on line # 15 <identifier> expected.
I think it's something else though, but can't figure it out.
It's thowing an exception now.

java.lang.NoClassDefFoundError: JdbcRowSetTest
Exception in thread "main"

The compiler keeps wanting ";"on the last 2 lines
Please help.
Curt
*/
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40


static final String DRIVER = "com,mysql.jdbc.Driver";
static final String DATABASE_URL = "jdbc:mysql://localhost/db challenge.mdb";


This isn't going to work... The mysql driver will not work for access. You need to get an access driver from Microsoft -- or use the JDBC/ODBC bridge. As for the format of the URL, there is no standard -- you have to use the format as defined for the driver that you using. Using the mysql format isn't going to work for the access driver, once you install it.

Henry
[ October 02, 2007: Message edited by: Henry Wong ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

You can use the following:
Driver = "sun.jdbc.odbc.JdbcOdbcDriver"
Database URL = "jdbc: odbc: DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" followed by the filename. (Remove the spaces before odbc and DRIVER; I HATE these smileys!)
[ October 03, 2007: Message edited by: Rob Prime ]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3645
    
  15
Rob - there's a 'Disable smilies in this post' option on the reply page.


Joanne
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Thanks, I never saw it. Probably because it is just outside my screen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jdbc