GeeCON Prague 2014*
The moose likes JDBC and the fly likes servlet jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "servlet jdbc" Watch "servlet jdbc" New topic
Author

servlet jdbc

Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Hello everyone am using windows 7 64 bit operating system and developing my first servlet which contains a database in it. can anybody tell me which DBMS should i use so that i can create a table and save records in it? Many thanks!!!
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Any relational DB can do that: Derby, HsqlDB, MySQL, PostgreSQL, Oracle, Informix, DB2, SQLServer, Sybase, ... That has nothing to do with servlets, though.
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Thanks for your reply Tim, but i tried using oracle but unfortunately there is no driver available with windows 7 64 bit like it needs ODBC driver for creating a dsn connection. many thanks..!!!
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
You definitely do not want to use ODBC with Oracle. On http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html I see no mention of any dependency of Oracle's JDBC drivers on some Windows version or other; are you sure about that?
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Tim, i have been taught that we should use JDBC-ODBC bridge and ODBC driver to connect your standalone or a web application to the database but i dont know if we can use or connect the application with the database using something else...please help..i know this may be funny for you but am sorry am very new to this all...thanks!!!
Daniel Val
Ranch Hand

Joined: Jan 09, 2012
Posts: 44
Pranit Sonawane wrote:Hello everyone am using windows 7 64 bit operating system and developing my first servlet which contains a database in it. can anybody tell me which DBMS should i use so that i can create a table and save records in it? Many thanks!!!


- Don't bother to connect using ODBC - there are jdbc drivers available for all the database servers and they work very well because they were developed by the same people who developed the actual server. The fastest in my opinion is to install mysql (comes with a very handy msi installer) and download the jdbc driver from the same place.
- Please don't use the DriverManager.registerDriver approach to get the connection, rather install the jdbc jar file in the application server classpath (lib folder for tomcat 6 - 7) and register a data source.

- As it was mentioned in other messages from this forum, accessing database from the presentation tier or controller should be avoided and instead you should define a service tier and access it from there. But if you just want to "see how it works" that's different.

D.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Pranit Sonawane wrote:Tim, i have been taught that we should use JDBC-ODBC bridge and ODBC driver to connect your standalone or a web application to the database

You need to unlearn that. The JDBC/ODBC bridge driver is buggy and not thread-safe; the latter point alone makes it unsuitable for web applications. The type of driver pretty much everyone uses these days is called type 4 driver, and that's what you'll find on that Oracle page.
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Thanks for all of your posts..seems really helpful am still going to experience a problem. please stay in touch and help me out with this. Appreciate your honestly. Many Thanks!!!
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Alright people now i need to download a database management system for my windows 7 64 bit please help me with this. I have oracle 10 g but dont have a driver to connect it and create a DSN. please help me with the link also. Many thanks!!!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

You do not want to use a DSN. That's still ODBC, and ODBC is terrible compared to a direct connection.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Siri Naray
Ranch Hand

Joined: May 19, 2006
Posts: 105
try the following in your Java code to connect to Oracle DB. Also copy ojdbc14.jar file to your current working directory and set class path.



set classpath=%classpath%;currentworkingdirectorypath.ojdbc14.jar;.

(the . at the end of classpath is also needed to set it to the current directory)
This should work.

This is a type 4 driver and there is no need to set DSN for this.

Hope this helps


If you worry you cannot work... If you work you need not worry
 
GeeCON Prague 2014
 
subject: servlet jdbc