File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Connecting to a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Connecting to a database" Watch "Connecting to a database" New topic

Connecting to a database

Eman Adenola

Joined: Apr 03, 2011
Posts: 27
Hello, I'm a new member, yep you guessed it.
I really need help understanding some concepts but I will like to take it one at a time.
The major problem is connecting to a database. The pdfs I got are lecturers' note pointless..
I am using the <sql:dataSource> tag to connect to a database...but the problem is i don't understand the attributes..

the driver attribute, from what I could glean helps the database to understand the java the java code is translated into the database language in order to understand and process it.
What i don't understand is..where can I find the correct driver to use? How do I know if it is the correct one to use..every tutorial as a different one I want to go crazy..
The same thing with the other url tag..apparent it is the url for where the database is located.
Since I am using Access how can I find the url of the database.
I have seen many rude comments about how Access is bad and everything..don't have a go at the student please :O..its for assignment

That is the driver in my lecturers I am using that..but i am not sure what url to use for the access.
I went to the datasource option and created a DataSource called access..But how do I link it to the Access database?
Please help a lost JSP programmer.
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
Damnit you already stole what I was going to say

Don't code SQL into a JSP page.
Don't use the JDBC-ODBC driver
Don't use Access :-)

However, if you have to because of whatever draconian limitations are put on you by your environment, you have to.
Its been a while since I did this so my memory might be a little rusty, but:

Googling took me to these pages which refreshed my memory a bit. I would suggest checking 'em out.

How do you link it to the Access database?
Via the DataSources(ODBC) control panel in windows.
You set up the DSN to point to your specific access database .mdb file.
Make sure you create a SYSTEM DSN, and not a user DSN.

Your URL from java then just becomes jdbc:odbc:[insert_name_of_DSN_here]
so jdbc:odbc:access would be correct.

Eman Adenola

Joined: Apr 03, 2011
Posts: 27
I got it to work, that was the problem I was setting it in User DSN.
Sorry I stole your thunder ;)...Yeah considering that our lecturers themselves told us last year not to use Access, its a hypocritical that we have to use it now..Ah well, it is for an assignment.

Can you explain what a data source is exactly..Is it like the name for a connection to a database or something. The explanations aren't quite clear.
And is it possible to have multiple databases/tables to a datasource. I tried and it always created a new datasource :S

Thanks for help
I agree. Here's the link:
subject: Connecting to a database
jQuery in Action, 3rd edition