Results 1 to 4 of 4

Thread: type 4 driver

  1. #1
    Dayanand is offline Member
    Join Date
    Feb 2011
    Posts
    61
    Rep Power
    0

    Default type 4 driver

    package com.lara;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class Mgr
    {
    public static void main(String[] args)
    {

    try
    {
    Class.forName("Oracle.jdbc.driver.OracleDriver");
    }
    catch (ClassNotFoundException e)
    {
    e.printStackTrace();
    }
    Connection con = null;
    Statement stmt = null;
    try
    {
    con = DriverManager.getConnection("jdbc:Oracle:thin:@loc alhost:1521:XE","system","mahesh");

    stmt = con.createStatement();
    stmt.execute("insert into persons values('abc','xyz',22)");
    System.out.println("done");
    }
    catch (SQLException e)
    {
    e.printStackTrace();
    }
    finally
    {

    }
    System.out.println("done");
    }
    }
    output:-

    java.lang.ClassNotFoundException: Oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.lara.Mgr.main(Mgr.java:14)
    java.sql.SQLException: No suitable driver found for jdbc:Oracle:thin:@localhost:1521:XE
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.lara.Mgr.main(Mgr.java:24)
    done


    i got an run time execption in the below statemnet
    con = DriverManager.getConnection("jdbc:Oracle:thin:@loc alhost:1521:XE","system","mahesh");

    what is the mistake i have done.?

  2. #2
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Is the space supposed to be there in between jdbc:Oracle:thin:@loc alhost:1521:XE

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default

    Oracle.jdbc.driver.OracleDriver
    Java is case sensitive, that first Oracle should be oracle.

    Presuming you have the odbc jar file on your runtime classpath.

  4. #4
    Dayanand is offline Member
    Join Date
    Feb 2011
    Posts
    61
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Oracle.jdbc.driver.OracleDriver
    Java is case sensitive, that first Oracle should be oracle.

    Presuming you have the odbc jar file on your runtime classpath.
    oh i got it.!!!!!!!!
    thanks a lot.........

Similar Threads

  1. Setting values from One Enum type to another enum type.
    By reach2sudhakar in forum New To Java
    Replies: 3
    Last Post: 09-23-2010, 06:02 PM
  2. Replies: 7
    Last Post: 11-20-2009, 03:02 AM
  3. using instanceof to get Object type and parent type?
    By xcallmejudasx in forum New To Java
    Replies: 2
    Last Post: 11-06-2008, 06:24 PM
  4. [SOLVED] Cast string type to int type
    By GilaMonster in forum New To Java
    Replies: 9
    Last Post: 09-17-2008, 10:43 AM
  5. Replies: 1
    Last Post: 08-08-2007, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •