Results 1 to 5 of 5
  1. #1
    kvk
    kvk is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default i got an error while run jdbc program..

    i am using the windows 7... while runing the jdbc program i got some errors...
    the code is

    import java.sql.*;
    import java.util.*;
    import java.io.*;
    class DBL
    {
    Connection con;
    Statement st;
    Scanner s;

    DBL(){

    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con=DriverManager.getConnection("jdbc:oracle:thin: @localhost:1521:xe","system","vijaya");
    st=con.createStatement();
    s=new Scanner(System.in);
    }
    catch(Exception e){
    e.printStackTrace();
    }
    }
    public void create(){
    try{

    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("enter table name");
    String tname=br.readLine();
    st.executeUpdate("create table "+tname+"(eno number,ename varchar2(10),esal number)");
    System.out.println("tasble created");



    }
    catch(Exception e){
    e.printStackTrace();
    }
    finally{
    try{
    con.close();
    }
    catch(Exception e){
    e.printStackTrace();
    }
    }
    }
    };
    class CreateEx{
    public static void main(String[] args)
    {
    DBL d=new DBL();
    d.create();
    }
    }
    and the errors are

    D:\programs>java CreateEx
    Error: Could not find main class CreateEx
    Exception in thread "main" java.lang.NoClassDefFoundError: CreateEx
    at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:198)

    Caused by: java.lang.ClassNotFoundException: CreateEx
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 299)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 288)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:287)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 22)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:325)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 55)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:195)

    ************88pls give me the solution*************

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default Re: i got an error while run jdbc program..

    Those exceptions have nothing to do with JDBC; the JVM simply can't find the class CreateEx. Take care that a compiled version is somewhere in your classpath.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

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

    Default Re: i got an error while run jdbc program..

    It's not a public class.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    kvk
    kvk is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Re: i got an error while run jdbc program..

    hi joshan....
    you are saying that the JVM simply can't find the class CreateEx...
    so,what i do sir...please tell solution for this clearly...

    i am set class path like this... i am saving the programs in d: drive

    d:>set classpath=%classpath%;c:\oraclexe\app\oracle\produ ct\10.2.0\server\jdbc\lib\ojdbc14.jar

    after set the classpath still the program is not executed sir...

    i am saving the programs in D-drive and i am compling the programs on the same drive....

    if you don't mind sir will please tell clearly....pls....

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

    Default Re: i got an error while run jdbc program..

    How are you running the code?
    What command are you using (the full command).
    Where is your compiled code in relation to where you run this command?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Help! JDBC Connection Error
    By pryncipe in forum New To Java
    Replies: 5
    Last Post: 03-19-2011, 04:03 PM
  2. jdbc connectivity error
    By OMFGITSROHIT in forum JDBC
    Replies: 2
    Last Post: 03-16-2010, 05:10 PM
  3. Replies: 0
    Last Post: 04-01-2008, 10:17 AM
  4. JDBC error
    By ARADHYEV in forum JDBC
    Replies: 0
    Last Post: 01-09-2008, 08:56 AM
  5. Replies: 0
    Last Post: 09-28-2007, 12:56 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
  •