
Import java.sql
javax.servlet
//all packages entered
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:CUSTOMER");
Statement st=con.createStatement();
// Execute an SQL query, get a ResultSet
ResultSet rs = st.executeQuery("SELECT NAME, ADDRESS FROM CUSTOMER");
// Display the result set as a list
}
catch(.......){}
ERROR MSG on cmd
DBPhoneLookup.java:26: incompatible types
found : java.sql.Connection
required: Connection
Connection con = DriverManager.getConnection("jdbc:odbc:CUSTOMER");
^
DBPhoneLookup.java:27: cannot find symbol
symbol : method createStatement()
location: class Connection
Statement st=con.createStatement();
^
i am confused what is the problem with this part of code

hi friend,
I think you should check the line of importing package of sql probably there may be a problem. Java is a case sensitive language. In your sample code I can see that you have used the Import java.sql instead of
import java.sql.Connection;
if the problem is not occurred due to the above reason probably there may be a problem in naming of a class. Check whether you have created a class by name "Connection" in your package
for detail tutorial you can go through the link Database Connectivity in Servlet
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.