wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC-ODBC(VERY VERY URGENT PLEASE) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC-ODBC(VERY VERY URGENT PLEASE)" Watch "JDBC-ODBC(VERY VERY URGENT PLEASE)" New topic
Author

JDBC-ODBC(VERY VERY URGENT PLEASE)

Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Hello,
I am working in Java. I don't know much about JDBC.
My company wants this:
-Make project using Java application. My Java application must connect to one database.
-Now when the product is in the market, we don't know what database type customer has whether it oracle or sql or db1? But we know that customer will have one only database.
-Now in my java application through JDBC, should able to connect automatically without specifying(what database type to my application) to that database and open the connection and with using general quary(should work with all database) make table, add data to that table.
My question is:
(1) Should Customer specify which database type to my application to JDBC? OR
My application with JDBC without specifying database type(Oracle,DB1) should be smart enough to connect to any database and use general query which should work with any database to make table, add rows, columns with data,retrieve data,query data?
Thanks,.
Angela
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Angela, this can be dangerous. I only say that because each database has subtle differences that can reduce your programs to unstable. For example, some MSAccess inserts through JDBC require a select statement for no reason at all after you insert a row to make the last insert work. If you don't, then it won't insert the last row in a series of inserts. Some databases don't support transactions, so you would have to eliminate them. Some databases have different syntax for joins, so you'd have to leave those out. Dealing with dates can be finicky too ( inserts, updates, etc. ). So, even though you may be able to connect to the database using similar JDBC-ODBC connection URL's ( ODBC data setup can be a headache too ), it doesn't guarantee that the rest of your jdbc code will function correctly. Because each different database has different strengths/weaknesses/limitations, you may find yourself pulling your hair out in the end. Maybe you could make it work with extensive testing on all possible database combinations, but expect some differences.
Jamie
[ June 06, 2002: Message edited by: Jamie Robertson ]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
A product like Jive which supports multiple database types allows the user to specify the database info at install time.
I would be very cautious about using ODBC in a production environment.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Statement:-
so,my application with JDBC without specifying database type(Oracle,DB1) should be smart enough to connect to any database and use general query which should work with any database to make table, add rows, columns with data,retrieve data,query data?
So this above statement not possible... Am I right?
Thanks,
Angela
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
The user would need to provide the necessary information for your application to run. They would have to give you the information for which class to use and which connection string to use. Then you just use regular JDBC. But I would not recommend using JDBC-ODBC. Last I checked it was not recommened for production.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Angela D'souza:
Statement:-
so,my application with JDBC without specifying database type(Oracle,DB1) should be smart enough to connect to any database and use general query which should work with any database to make table, add rows, columns with data,retrieve data,query data?
So this above statement not possible... Am I right?
Thanks,
Angela

Remember, JDBC-ODBC relies on the computer to be set up with a DSN. It doesn't just know where the database is. This means that you need to set up each users computer to use it. If you use a different jdbc driver ( vendor specific ), each deployment may have their database in different locations with different names, using different ports ( requires different connection URL ), so this will need to be specified at the time of writing the code, or you may be able to do it at set-up/deployment time. Not to mention that the vendor specific drivers usually have their own unique URL format used in the connection.
Jamie
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

You might want to look at this link to find out the limitations of the jdbc odbc bridge. As Paul stated earlier, this is a direct quote from Sun:
"Note, however, that you should use the JDBC-ODBC Bridge only for experimental prototyping or when you have no other driver available."
I'm sure that what you are trying to acclomplish can be done, in some way, as anything is possible...but it may take more time and effort than you may be willing to put into it. If your looking for an answer to your question like "Yes, it can be done...this is how", then I think you're out of luck...unless anyone else has suggestions??
Jamie
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

...and maybe someone else out there has already made such a driver. You might want to investigate purchasing a "universal driver". Not sure if one exists, but someone might have already put the time and effort into such a product. Do a search here to see if you can find what you are looking for
good luck and keep us informed of your solution,
Jamie
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Originally posted by Jamie Robertson:

Remember, JDBC-ODBC relies on the computer to be set up with a DSN. It doesn't just know where the database is. This means that you need to set up each users computer to use it. If you use a different jdbc driver ( vendor specific ), each deployment may have their database in different locations with different names, using different ports ( requires different connection URL ), so this will need to be specified at the time of writing the code, or you may be able to do it at set-up/deployment time. Not to mention that the vendor specific drivers usually have their own unique URL format used in the connection.
Jamie

Jamie, I mean to write that I can provide name and location and port number of database to java application but I can't provide the database type i.e. whether it's oracle or DB2 or SQL. Becuase in the market we don't know what database type customer is using. So, my question is:
IF I DON'T SPECIFY DATABASE TYPE i.e. ORACLE, SQL or DB2, is jdbc without getting database type parameter is smart enough to open the connection to database and add, remove, update the table to database???
Please also write me what is best solution?
Thanks a lot,
Angela
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Originally posted by Thomas Paul:
Then you just use regular JDBC. But I would not recommend using JDBC-ODBC. Last I checked it was not recommened for production.

Can I use just JDBC instead of JDBC-ODBC to connect to databases?
Thanks,
Angela
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Angela, as already posted, without knowing the database type, you may limit yourself to the portability of your code. Because of the differences in the way some of these databases handle things, you will have to make your code as generic as possible.
JDBC-ODBC is a bridge that aids in your connection to certain databases. JDBC is the API itself. You will still need a suitable driver for the database that will be used. I suggest that you take a look at the JDBC tutorial at Sun's site since you are new to JDBC.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Thanks,
Angela
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC-ODBC(VERY VERY URGENT PLEASE)
 
Similar Threads
How to store & retrieve a video file from database?
Requirements for building Java GUI to access MySQL Database
database & JDBC
Connection between two databases
Using other JDBC driver version within JDeveloper