java servlet connectivity problem with access

Ads
 

java servlet connectivity problem with access

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
View Answers

January 28, 2013 at 12:07 PM

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

Ads









Related Tutorials/Questions & Answers:
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName...=con.createStatement(); ^ i am confused what is the problem
Java Servlet Problem - JSP-Servlet
Java Servlet Problem  I have a servlet class that implemets..., but in the attributeReplaced() method, i want to perform a redirect to another servlet... method. Please help!!  Hi friend, Please explain problem
Advertisements
connectivity with access
connectivity with access  how to connect with data base with access...; Is this Access database or excel sheet. Do you want to display the values...;Is this Access database or excel sheet. Do you want to display the values in Textarea
connectivity problem
connectivity problem  i am facing error in Class.for name statement... connectivity still i am facing this error* ================================oracle connectivity program============================ import java.sql.*; import
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**  <p>...; data sources. 2)Click Add button and select the driver Microsoft Access Driver
Access 2007 database connectivity
source and destination. pls tell me the code of connectivity with access 2007...Access 2007 database connectivity  i design an application form that have two JComboBox as the label(source,destination) and two JButton save
oracle connectivity problem with netbeans
oracle connectivity problem with netbeans  sir I am using oracle.... for this after adding new driver(ojdbc6.jar) in services tab I got connectivity with oracle... of simple connectivity with oracle in this I am giving driver details
Servlet problem
connectivity code it works but problem is with servlet page. My servlet code...Servlet problem  Hello, I am very shocked about this mysterious problem from last three month and now i hope rose india developers
servlet problem
servlet problem  wheni m deploying an servlet application im getting trouble context [/filename] startup failed due to previous error in tomcat 6.0.
database connectivity problem
database connectivity problem  what if client dont have database with them then what is other way to run successfully our programm   Please visit the following link: http://www.roseindia.net/jdbc
jdbc oracle connectivity problem
jdbc oracle connectivity problem  Hi All, I am trying to connect my swing application to oracle DB . but class.forname is giving error. Please suggest me if there is some different way to connect swing application to oracle
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
problem running a servlet on tomcat.
problem running a servlet on tomcat.  i have followed the steps given... to run my servlet that is placed in the directories as it has been mentioned here, the browser responds "HTTP Status 404 - /java_mail/hello" wht could
java connectivity
java connectivity  hi........ Can u help me to do connectivity between java and weka??????? weka is a data mining tool which allows to do prediction, classification etc.... i want to do connectivity between weka and java can u
problem in servlet program
problem in servlet program  Dear Sir, I have a problem to insert the Blob type data like as video file, audio file in the database using Servlet and html code
java connectivity
java connectivity  i am trying to add dyanamic rows in the jsp page, when i add the new row the dropdown control value is not coming from database..please help me to overcome this problem
how to solve this problem for oracle connectivity
how to solve this problem for oracle connectivity  Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish the connection
sql connectivity through java
sql connectivity through java  i want an example for java db through sql connection. Thanks in advance
problem in jsp using ms-access
problem in jsp using ms-access  after starting server(tomcat) wen v... and select the driver Microsoft Access Driver(*.mdb). 3)After selecting... the driver Microsoft Access Driver(*.mdb). 3)After selecting the driver, click
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting...,since i try to configure this out for 1 week,i dont find any solution for my problem. T_T I have develop my java web application in window Environment and now i
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatc‚?¶ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
servlet redirect problem help needed
servlet redirect problem help needed  package p; import...=getServletContext().getRequestDispatc‚?¶ re.forward(req, resp); } } this servlet is calling by a jsp..there is no problem,in this servlet the if condition always
JAVA CLASSPATH PROBLEM
JAVA CLASSPATH PROBLEM  hi all Friends I am stuck using the java servlets and problem raise for classpath. I had a problem with servlet to call... that it didn't found any java class (which is java class calling from servlet). but i
java servlet
java servlet   im using ubuntu 12.04 and ialready installed eclipse but i dont know how to run the servlet programs please give brief procedure to run the servlet program in eclipse
Java to SQL Server Connectivity
Java to SQL Server Connectivity  Hi, heres my code private void... with sql server connectivity at the background to save the data. Now, after... the connectivity wrong. Kindly help me resolve this issue ASAP. Thank you
Problem in uploading java application
Problem in uploading java application  I have uploaded my java... is running in local machine properly.But while trying to access the hosted... this problem
problem of static in jsp page by multiple user access
problem of static in jsp page by multiple user access  hi , i am continuing my online exam project,but i have a Singleton class which i am invoking from my jsp page , ths page can access by more number of users .every user
java Problem
java Problem  I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me. Thanks in advance
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
JAVA Problem
JAVA Problem  Write a program that takes two parameters 1. a word 2. an array of words It should then remove all instances of the word in the array. For Example: INPUT word="ravi" word_array = ["Chethan Bhagat
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page

Ads