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 2 of 2

Thread: sqlexception

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default sqlexception

    I have created database in myAccess while reading data from ms-access i am getting following error:
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    This is my java program
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;


    public class AccessDatabase {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Connection con = null;
    Statement stmt = null;
    try {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection( "Jdbc:Odbc:mydb", "","");
    stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select * from users");
    while (rs.next()) {
    System.out.println(rs.getString("uname") + " "
    + rs.getString("pwd"));
    }
    } catch (Exception e) {
    System.out.println(e);
    } finally {
    if(con!=null){
    try {
    con.close();
    con = null;
    } catch (SQLException sqlEx) {
    sqlEx.printStackTrace();
    }
    }

    if(stmt!=null){
    try {
    stmt.close();
    stmt = null;
    } catch (SQLException sqlEx) {
    sqlEx.printStackTrace();
    }
    }
    }

    }

    }

    Anybody help me???


  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: sqlexception

    The Exception say it all.
    Also look at the method signature and parameters for getConnection method.

Similar Threads

  1. Replies: 2
    Last Post: January 9th, 2012, 10:03 AM
  2. java.sql.SQLException: No data found
    By Virender in forum JDBC & Databases
    Replies: 2
    Last Post: December 7th, 2011, 01:17 PM
  3. Replies: 2
    Last Post: November 17th, 2011, 08:03 AM
  4. Replies: 6
    Last Post: August 18th, 2010, 06:41 PM
  5. Replies: 6
    Last Post: August 30th, 2009, 05:31 AM