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???