java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Here is the code:
import java.sql.*;
import java.util.*;
class database_main {
public static void main(String args[])
{
Connection con;
Statement stmt;
String url;
String sql;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce) {
System.out.println(ce);
}
try{
url="jdbc:odbc:test";
con=DriverManager.getConnection(url);
sql="Delete from friends where rtrim(name) like \'Kim\';";
System.out.println(" ");
stmt=con.createStatement();
stmt.executeUpdate(sql);
System.out.println("Record for Kim has been deleted");
con.close();
con=DriverManager.getConnection(url);
sql = "Update friends set city = \'Denver\' where rtrim(name) like \'Melinda';";
System.out.println(" ");
stmt=con.createStatement();
stmt.executeUpdate(sql);
System.out.println("Record for Melinda updated.");
}
catch(SQLException ce) {
System.out.println(ce);
}
}
}


Sign In
Create Account


Back to top









