Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help!!!

Status
Not open for further replies.

tmpalaniselvam

Programmer
May 14, 2000
68
IN
How do MS Access & Oracle connection interfaces implement  in  jdbc?
 
Hi!<br>I developed an application using Oracle db. I had to use a zip file with classes that allow oracle connection. The file is available (with documentation and examples) at Oracle site. It tells you how to create a connection in java code. For Access, I think you have to use jdbc-odbc. Hope I helped you..<br>The thread about formatted text is mine. If you have a minute, give it a look! PLEASE...<br>Vale
 
You would need to connect to the ODBC driver like this..<br>try {<br>Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;);<br>&nbsp;&nbsp;}<br>catch (Exception e)<br>{ System.err.println(&quot;Can not find driver &quot;+e);<br>&nbsp;}<br><br>then you connect to the database it self<br>&nbsp;try {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conSql = DriverManager.getConnection(&quot;jdbc:eek:dbc:JavaDB&quot;, &quot;&quot;, &quot;&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;catch (Exception e)<br>&nbsp;&nbsp;{ System.out.println(&quot;DAtabase is not connected&quot;);<br>&nbsp;&nbsp;&nbsp;}<br><br>conSql is a variable of type Connection.<br>So some where in my declarations I have<br>Connection conSql = null;<br><br>Note JavaDB is the name of your DSN (DataSourceName)<br>which implies you must register your Access database with ODBC and so provide a DSN.<br>(Just go to ControlPanel, ODBC datasources)<br>For this program I used Access Database<br>
 
Here's some source for how I did it in Oracle (that's slightly different from the ODBC source above):<br><br>#1: in my classpath, I have a link to a .JAR file called Oracle.jar; that's where my Oracle jdbc driver is located.<br>Inside of that .JAR file is the path &quot;oracle/jdbc/driver/OracleDriver&quot; - that might be different for you, so your &quot;Class.forName&quot; statement might be different. As valeriazava said, this file is available at Oracle's site (you'll have to register to download Oracle software).<br><br>By the way... all of this data is located in a method that throws ClassNotFoundException and SQLException so I don't have to deal with try/catch blocks in that section, I can deal with them easily outside of that method- but this is really up to you.<br><br>Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;);<br>Connection con = DriverManager.getConnection(url,usrname,psword);<br><br>url is where your database is kept; usrname and psword are somewhat self-explanatory. Best of luck! <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
I am also having some problem in connecting with Oracle db thru oracle native driver i.e. (&quot;oracle.jdbc.driver.OracleDriver&quot;).

I want to connect to the starter database provided with Oracle Personal Edition i.e. ORCL.

The path of the database is &quot;C:\ORACLE\ORADATA\ORCL&quot;.

What should be my URL in the statement
&quot;Connection con = DriverManager.getConnection(url,usrname,psword);&quot;

Should it be (&quot;ORCL&quot;, &quot;scott&quot;, &quot;tiger&quot;) or
(&quot;C:\ORACLE\ORADATA\ORCL&quot;, &quot;scott&quot;, &quot;tiger&quot;).

Please help.

Thanks in advance.

Ketan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top