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

JDBC Drivers?? Help Please

Richa Jeetah
Greenhorn

Joined: Sep 27, 2001
Posts: 29
I am having a hard time understanding something that might be simple..... PLEASE HELP !
I am trying to write a program ,,,,,,,,

import java.sql.*;
import java.io.*;
public class JavaSql1 {
public static void main(String str[]){
Statement stat;
ResultSet rs;
Connection conn;
try{
Class.forName("*** What do i write here *** "); //what Driver name to specify ??
conn = DriverManager.getConnection("*** What do i write here *** "); // HOw do i specify database name ??
stat = conn.createStatement();
rs = stat.executeQuery("Select * From My_Reminders");
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("NO. of Clouumns is: " + rsmd.getColumnCount());
for (int i = 0; i <= (rsmd.getColumnCount()); i++)
{
String name = rsmd.getColumnName(i);
System.out.println( name +"/t"+ rsmd.getColumnType(i));
}
stat.close();
conn.close();
}
catch(Exception e){
System.out.println("error");
}
}
}

I am working on Windows 2000
I Am using jdk1.3.1_01
i set the path to "h:\jdk1.3.1_01\bin"
Wish to assess my Database which is in Oracle 9i
Database name "HOME"
and my Program "JavaSql1.java is saved in "h:\My Java"
Where do i see the list of various drivers i have on my system...how do i set it ??
HOw do i know which one to use ?
Your help is greatly appreciated
Thanks
[ March 13, 2002: Message edited by: Richa Jeetah ]
Craig Demyanovich
Ranch Hand

Joined: Sep 25, 2000
Posts: 173
Although the JDBC API insulates you from many database-specific things, a few remain. You'll have to consult the documentation for your database/JDBC driver, in your case, Oracle 9i.
First, ensure that the appropriate driver, according to Oracle's documentation for your version, is on your classpath. Oracle usually includes the driver(s) with the database, and the drivers are available via download as well at the Oracle Technology Network.
Second, consult the documentation to see what the appropriate driver classname is and what the url syntax is.
(Most documentation that I've used is very clear on the above two issues; where it tends to be lacking is in troubleshooting information, what types of errors cause what exceptions).
Finally, to aid in troubleshooting your program, instead of printing "error" when you catch the exception, print the message of the exception via its getMessage() method or the exception as a string via its toString() method.
Good luck,
Craig
Richa Jeetah
Greenhorn

Joined: Sep 27, 2001
Posts: 29
Originally posted by Craig Demyanovich:
Although the JDBC API insulates you from many database-specific things, a few remain. You'll have to consult the documentation for your database/JDBC driver, in your case, Oracle 9i.
First, ensure that the appropriate driver, according to Oracle's documentation for your version, is on your classpath. Oracle usually includes the driver(s) with the database, and the drivers are available via download as well at the Oracle Technology Network.


How do i know if i have the paaropriate driver or not ?
what is the meaning of this error:
Exception in thread "main" java.lang.NoClassDefFoundError: JavaSql5
[ March 13, 2002: Message edited by: Richa Jeetah ]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

These should be all the Oracle resources you need to get started, get familiar with jdbc, trouble shoot your problems, and eventually become advanced!
1. download your oracle drivers at http://technet.oracle.com/software/tech/java/sqlj_jdbc/content.html and follow the download procedures (Click the link "Oracle9i 9.0.1 JDBC Drivers for use with JDK 1.2.x/JDK 1.3.x for NT" --> then check all the checkboxes --> then click on "JDBC-Thin, 100% Java ( 1,081 kb)")
2. enable the client to connect(set environment):
Setting Up Your Environment
---------------------------
On Win95/Win98/NT:
- Add [ORACLE_HOME]\jdbc\lib\classes12.zip and
[ORACLE_HOME]\jdbc\lib\nls_charset12.zip OR add to your CLASSPATH C:\temp\classes12.zip if you downloaded classes12.zip to the c:/temp directory.
**note: classes12.zip is the name of the file that you downloaded in step 1 (do not unzip!)
RESOURCES
3. All the Oracle specific code that you could ever need -->look for the "JDBC Samples" links
4. code snippets that explain various tasks(i.e. connection procedures...:

if you come accross a problem, check this list before you post

if you come accross an Oracle SQLException, then you can investigate the ORA-XXXXX error messages and solutions

good luck,
Jamie
[ March 13, 2002: Message edited by: Jamie Robertson ]
hob hartman
Greenhorn

Joined: Mar 04, 2002
Posts: 11
Richa,
In Windows control panel, select the ODBC Data Sources. Then select the drivers tab to see the drivers that are registered on your machine. If no Oracle driver is listed then download one. It will show up here after you download it.
hob
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC Drivers?? Help Please
 
Similar Threads
Loading Oracle JDBC Driver
JDBC
Making ResultSet unEditable
Loading Oracle JDBC Driver
Making ResultSet unEditable