I have a class
XDatabase.java
which performs all database functions (DML and DDL)correctly. This is a chunk of code..
public class XDatabase
{
Connection con = null;
Statement stmt = null;
ResultSet rset = null;
//Constructor
public XDatabase()
{
}
//Get database connection
public void connectDatabase(String driver,String ip,int port, String SID, String userName,
String password)
{
try
{
Class.forName(driver);
System.out.println("Connecting to the local database");
//Assembling connection String
String dbUrl ="jdbc:oracle:thin:@"+ip+":"+port+":"+SID;
con = DriverManager.getConnection(dbUrl,userName,password);
System.out.println("Connection successsful!!! ");
}
catch(Exception e)
{
System.out.println("Error in connection ");
e.printStackTrace();
}
}// End Constructor
Now when i create a project in JBuilder, and use the same fuction as above it gives me exceptions while loding the driver at line
Class.forName(driver)
The exceptions are as under:
C:\JBuilder9\jdk1.4\bin\javaw -classpath "C:\cvsroot\ibill\itariff\gui\iTariff\classes;C:\JBuilder9\lib\jbcl.jar;C:\JBuilder9\lib\dx.jar;C:\JBuilder9\lib\beandt.jar;C:\JBuilder9\jdk1.4\jre\lib\rt.jar;C:\JBuilder9\jdk1.4\jre\lib\i18n.jar;C:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;C:\JBuilder9\jdk1.4\jre\lib\jsse.jar;C:\JBuilder9\jdk1.4\jre\lib\jce.jar;C:\JBuilder9\jdk1.4\jre\lib\charsets.jar;C:\JBuilder9\jdk1.4\jre\classes;C:\JBuilder9\jdk1.4\lib\tools.jar" itariff.XTariff
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at itariff.XChargeSch.btnAdd_actionPerformed(XChargeSch.java:208)
at itariff.XChargeSch_btnAdd_actionAdapter.actionPerformed(XChargeSch.java:248)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
Error in connection
Please I need a quick solution.
Regards