P
Piotre Ugrumov
I have tried to catch from a database some information but when I try to
start the program I receive this message:
java.sql.SQLException: No suitable driver
This is the code of the program:
import java.sql.*;
import sun.jdbc.odbc.*;
import java.util.*;
public static void main(String[] args){
String fin="";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:dbc::museo");
PreparedStatement st=con.prepareStatement("SELECT ID FROM museo
WHERE Periodo=?");
st.setString(1, "800");
ResultSet rs = st.executeQuery();
if(rs.next()){
fin+=rs.getString("ID") + "\n";
// a += Integer.parseInt(dim);
}
}catch(SQLException e){
System.out.println(e);
}catch(ClassNotFoundException e){
System.out.println(e);
}
System.out.println(fin);
System.exit(0);
}
I compile this program without problems.
I have inserted a database created with access in the ODBC. I have add the
database in the System DNS.
How can I resolve the problem?
Thanks.
start the program I receive this message:
java.sql.SQLException: No suitable driver
This is the code of the program:
import java.sql.*;
import sun.jdbc.odbc.*;
import java.util.*;
public static void main(String[] args){
String fin="";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:dbc::museo");
PreparedStatement st=con.prepareStatement("SELECT ID FROM museo
WHERE Periodo=?");
st.setString(1, "800");
ResultSet rs = st.executeQuery();
if(rs.next()){
fin+=rs.getString("ID") + "\n";
// a += Integer.parseInt(dim);
}
}catch(SQLException e){
System.out.println(e);
}catch(ClassNotFoundException e){
System.out.println(e);
}
System.out.println(fin);
System.exit(0);
}
I compile this program without problems.
I have inserted a database created with access in the ODBC. I have add the
database in the System DNS.
How can I resolve the problem?
Thanks.