Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: ms-acess with jdbc

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow ms-acess with jdbc

    // Access.java
    import java.sql.*;
    public class AccessTest

    {
    public static void main(String [] args) throws Exception
    {
    try
    {




    //register driver and establish the connection
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con =DriverManager.getConnection("jdbcdbc:accdsn");
    //create statement object
    Statement st =con.createStatement();
    //send and execute query
    ResultSet rs =st.executeQuery("select * from student");
    // precess the result object
    while(rs.next())
    {
    System.out.println(rs.getInt(1)+" "+rs.getString(2)+" " +rs.getString(3));
    }
    //close jdbc objects
    rs.close();
    st.close();
    con.close();
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }



    }//main()

    }//class

    i am getting run time error in xp3 please help to me....................


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ms-acess with jdbc

    Please copy the full text of the error message and paste it here.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ms-acess with jdbc

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\admin>d:

    D:\>javac SelectTest.java

    D:\>java SelectTest
    Exception in thread "main" 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 SelectTest.main(SelectTest.java:11)

    D:\>cd ms access

    D:\ms access>javac AccessTest.java

    D:\ms access>java AccessTestt k
    Exception in thread "main" java.lang.NoClassDefFoundError: AccessTestt
    Caused by: java.lang.ClassNotFoundException: AccessTestt
    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)
    Could not find the main class: AccessTestt. Program will exit.

    D:\ms access>java AccessTestt
    Exception in thread "main" java.lang.NoClassDefFoundError: AccessTestt
    Caused by: java.lang.ClassNotFoundException: AccessTestt
    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)
    Could not find the main class: AccessTestt. Program will exit.

    D:\ms access>java AccessTest
    java.sql.SQLException: No data found
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknow n Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at AccessTest.main(AccessTest.java:13)

    D:\ms access>javac ConnectionExample.java
    javac: file not found: ConnectionExample.java
    Usage: javac <options> <source files>
    use -help for a list of possible options

    D:\ms access>cd\

    D:\>javac ConnectionExample.java

    D:\>java ConnectionExample
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not fou
    nd and no default driver specified

    D:\>javac ConnectionExample.java

    D:\>javac AccessTest.java
    javac: file not found: AccessTest.java
    Usage: javac <options> <source files>
    use -help for a list of possible options

    D:\>cd ms access

    D:\ms access>javac AccessTest.java

    D:\ms access>java AccessTest
    java.sql.SQLException: No data found
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknow n Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at AccessTest.main(AccessTest.java:13)

    D:\ms access>java AccessTest
    java.sql.SQLException: No data found
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknow n Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at AccessTest.main(AccessTest.java:13)

    D:\ms access>javac AccessTest.java

    D:\ms access>java AccessTest
    Exception in thread "main" java.lang.ClassNotFoundException: sun.jdbc.odbc.Jdbco
    dbcDriver
    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 AccessTest.main(AccessTest.java:12)

    D:\ms access>

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ms-acess with jdbc

    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    Where is the definition for the class named in the error message?
    Its definition must be on the classpath so the java program can find it.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ms-acess with jdbc

    please check my message and check it and give the answer as soon as possible... please

    --- Update ---

    class not found
    my sql exception no data found it gives please tell message

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ms-acess with jdbc

    Where is the definition for the class that was not found? Its definition must be on the classpath for the java command.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Feb 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ms-acess with jdbc

    Quote Originally Posted by Norm View Post
    Where is the definition for the class that was not found? Its definition must be on the classpath for the java command.
    how to define please tell to me i am beginner of jdbc please tell to me:

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ms-acess with jdbc

    Where is the definition for the class? It could be in a jar file.

    i am beginner of jdbc
    See the tutorial: http://docs.oracle.com/javase/tutorial/jdbc/index.html
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Feb 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ms-acess with jdbc

    it is present in oracle or java jdk 1.6 please tell

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ms-acess with jdbc

    Sorry, I don't understand your question.

    Did you read the tutorial? It should all be explained there.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Feb 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: ms-acess with jdbc

    i am trying to connect with ms-access it gives run time error class not found if u have videos of ms-access

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: ms-acess with jdbc

    Where is the definition for the class that is not found?
    You have to find that class's definition so you can put it on the classpath.


    I've moved the thread to the JDBC section of the forum.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Acess methods
    By Truck35 in forum Object Oriented Programming
    Replies: 3
    Last Post: January 29th, 2013, 12:05 PM
  2. JDBC Problem - com.mysql.jdbc.Driver
    By icu222much in forum Java Servlet
    Replies: 2
    Last Post: November 21st, 2011, 11:54 PM
  3. jdbc
    By kundalikk in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 2nd, 2011, 04:38 AM
  4. JDBC
    By Abdul Rasheed in forum JDBC & Databases
    Replies: 1
    Last Post: August 13th, 2010, 07:01 AM
  5. Help with JDBC
    By michaelmel in forum JDBC & Databases
    Replies: 0
    Last Post: May 14th, 2010, 07:11 AM