Skip to main content

error occured

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
naggjl
Offline
Joined: 2011-11-26

when the i compile the following application 1 error occured in the following

jdbcex13.java:28: cannot find symbol
symbol : method preparedStatement(java.lang.String)
location: interface java.sql.Connection
pst=con.preparedStatement("insert into emp3 values(?,?,?)");

application: ^

import java.sql.*;
import java.*;
import java.io.*;
import java.lang.*;
class DBL
{
PreparedStatement pst;
Connection con;
Console c;
DBL()
{
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","tiger");
c=System.Console();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void insert()
{
try
{
pst=con.preparedStatement("INSERT INTO EMP3 VALUES(?,?,?)");
while(true)
{
int eno=Integer.parseInt(c.readLine("Enter Employee number :"));
String ename=c.readLine("Enter Employee Name :");
float esal=Float.parseFloat(c.readLine("Enter Employee Salary :"));
pst.setInt(1,111);
pst.setString(2,ename);
pst.setFloat(3,esal);
String option=c.readLine("One more read[y/n]");
if(option.equals("n"))
break;
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
con.close();
}
catch (Exception e)
{
}
}
}
};
class jdbcex13
{
public static void main(String[] arg)
{
DBL d=new DBL();
d.insert();
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vlsn.kakitha
Offline
Joined: 2011-12-09

We don't have a method as preparedStatement(String) in Connection interface. Change the method name to prepareStatement(String) and check once.