permaculture playing cards*
The moose likes JDBC and the fly likes JDBC /ODBC connectivity 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 connectivity" Watch "JDBC /ODBC connectivity" New topic
Author

JDBC /ODBC connectivity

nachiket deshpande
Ranch Hand

Joined: Oct 06, 2000
Posts: 114
Hi all!
I am new to JDBC forum.i have oracle 7 on my machine.and want
to establish connectivity with my database.I have read JDBC2.0
from jdk1.3 but unfortunately i am not able to connect my data
with my java programme.can someone helpme with detailed
connectivity code.I dont think we need drivers to
be loaded for local programmes on machine??please help
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
If you are using Sun's JDBC-ODBC bridge driver, you will have to set up an ODBC DSN to your Oracle database, which will require that you have a driver present on your local machine. You would have that driver if you had the Oracle client installed. If you are saying that your machine is both the client and the server, then I would recommend that you not try to dink around with ODBC. Sun's driver is only a reference implementation anyway, and not suitable for deployment. You can go to Oracle's web site and download their pure Java JDBC driver for free. It will be faster and easier. Then all you have to do is unzip it into your classpath and import it into your class file. Be sure to take a look at the documentation while you are out there so you can note the correct URL for your JDBC driver and it's proper connect string.
nachiket deshpande
Ranch Hand

Joined: Oct 06, 2000
Posts: 114
Thanks Bodie!
At present i am using sun's jdbc dbc driver.and got the connectivity.now i want to insert a new row using moveToInsertRow () method but the error is ArrayIndexOutOfBound exception.Please help.my code is
import java.sql.*;
public class jump{
public static void main(String[] args)throws SQLException,
ClassNotFoundException{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc dbc:dsn_sample";
Connection con=DriverManager.getConnection(url,"scott","scott");
System.out.println("Connected to DB");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("SELECT * FROM ball");
System.out.println("Successfully executed the query");
rs.moveToInsertRow();
rs.updateString("name","ram");
rs.updateInt("age",38);
rs.updateString("color","black");
rs.insertRow();
rs.moveToCurrentRow();
String s,s1;
while (rs.next()) {
s=rs.getString("name");
int i=rs.getInt("age");
s1=rs.getString("color");
System.out.println("ROW="+s +" "+i+ " "+s1);
}
rs.close();
stmt.close();
con.close();
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC /ODBC connectivity
 
Similar Threads
How to use File DSN in JDBC
JDBC2.0
NEWBIE: Web Browser Front End
Redhat Linux 7.0 and jdbc connectivity
jdbc connectivity in applet