Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jdbc

 
Curtis Bridges
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Curtis Bridges
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20999
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*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
Marshal
Pie
Posts: 20999
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob - there's a 'Disable smilies in this post' option on the reply page.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I never saw it. Probably because it is just outside my screen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic