aspose file tools*
The moose likes JDBC and the fly likes Need a help wilh MSAccess Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need a help wilh MSAccess" Watch "Need a help wilh MSAccess" New topic
Author

Need a help wilh MSAccess

Ahamed Sharif
Ranch Hand

Joined: Aug 24, 2003
Posts: 47
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

Joined: Aug 24, 2003
Posts: 47
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need a help wilh MSAccess