• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a help wilh MSAccess

 
Ahamed Sharif
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am running a simple java program to test DB.I am using MSAccess 2000
and jdk1.4 . But it was showing error like "SQLException: [Microsoft][ODBC
Driver Manager] Data source name not found and no default driver specified"
Please any can help me.
I gave DNS name as usda.

Source::
import java.sql.*;

public class SimpleJDBC {
public static void main(String args[]){
String url = "jdbc dbc:usda";
Connection con;
Statement stmt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url);
stmt = con.createStatement();
ResultSet uprs = stmt.executeQuery("SELECT * FROM FirstDB");
while (uprs.next()) {
String s = uprs.getString("USERNAME");
String s1 = uprs.getString("PASSWORD");
System.out.print(s + " " + s1);
}
uprs.close();
stmt.close();
con.close();
}
catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
Thanks,
Sharief.
 
Ahamed Sharif
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I got it.

Originally posted by Ahamed Sharif:
Hi,
I am running a simple java program to test DB.I am using MSAccess 2000
and jdk1.4 . But it was showing error like "SQLException: [Microsoft][ODBC
Driver Manager] Data source name not found and no default driver specified"
Please any can help me.
I gave DNS name as usda.

Source::
import java.sql.*;

public class SimpleJDBC {
public static void main(String args[]){
String url = "jdbc dbc:usda";
Connection con;
Statement stmt;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url);
stmt = con.createStatement();
ResultSet uprs = stmt.executeQuery("SELECT * FROM FirstDB");
while (uprs.next()) {
String s = uprs.getString("USERNAME");
String s1 = uprs.getString("PASSWORD");
System.out.print(s + " " + s1);
}
uprs.close();
stmt.close();
con.close();
}
catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}
Thanks,
Sharief.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic