Home » Developer & Programmer » JDeveloper, Java & XML » oracel not connect wiht java (netbeans)
oracel not connect wiht java (netbeans) [message #207764] Wed, 06 December 2006 23:40 Go to next message
mfa786
Messages: 210
Registered: February 2006
Location: karachi
Senior Member

hi master
1.
sir i use netbeans with oracle but oracle 9i not connect i send you my class code and error

class code
=========
/*
* Waheed.java
*
* Created on December 6, 2006, 5:44 PM

import java.sql.*;
*
* @author Administrator

public class Waheed {

public Waheed() {
}
public static void main (String args []) throws SQLException
{
System.out.println ("going for connection");
// DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

try{
Class.forName("oracle.jdbc.driver.oracleDriver");

Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@fahim:1521:aamir","muhammad","mfa786");
// @machineName:port:SID, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select accid from accbal");
System.out.println ("going for connection");
while (rset.next())
// System.out.println (rset.getString("accid")); // Print col 1
System.out.println (rset.getString("in loop"));
// stmt.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}


=
error ===

going for connection
java.lang.ClassNotFoundException: oracle.jdbc.driver.oracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at Waheed.main(Waheed.java:23)

===


sir i am also use this code

import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@hostname:1526:orcl","scott","tiger");
// @machineName:port:SID, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
}
}


but netbeans give me driver not match error

2..

sir by using netbeans runtime i connect oracle 9i and brows the all table
can i use that runtime object in my class then not use
this code

import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@hostname:1526:orcl","scott","tiger");
// @machineName:port:SID, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
}
}


directly use runtime object

please give me both idea with sample code

thank's

aamir
Re: oracel not connect wiht java (netbeans) [message #208216 is a reply to message #207764] Fri, 08 December 2006 11:50 Go to previous message
asangapradeep
Messages: 128
Registered: October 2005
Location: UK
Senior Member
is the ojdbc14.jar file is in the class path?
Previous Topic: which command will use to start the form developer...
Next Topic: Oracle Java system parameters
Goto Forum:
  


Current Time: Fri Nov 22 04:09:00 CST 2024