Problems with jdbc-odbc

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::eek: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.
 
T

Tony Morris

Piotre Ugrumov said:
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::eek: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.

Your JDBC URL is incorrect. Reread the documentation for the JDBC-ODBC
bridge.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top