编译错误 "cannot find symbol"
Compilation error "cannot find symbol"
我正在尝试将数据插入 MySQL,但出现错误:
cannot find symbol c
import java.sql.*;
class Insert{
public static void main(String args[]){
try{
Class.forName("com.jdbc.mysql.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3036/db","ravi","ravi");
//showing error in the below statement at c
Statement stmt = c.CreateStatement();
int result=stmt.executeUpdate("Insert into emp values(3,'david',33) ");
System.out.println("success");
c.close();
} catch(Exception e) {
System.out.println(e);
}
}
}
是 c.createStatement()
而不是 c.CreateStatement()
。
您需要将方法名称中的 c
设为小写 createStatement()
我正在尝试将数据插入 MySQL,但出现错误:
cannot find symbol c
import java.sql.*;
class Insert{
public static void main(String args[]){
try{
Class.forName("com.jdbc.mysql.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3036/db","ravi","ravi");
//showing error in the below statement at c
Statement stmt = c.CreateStatement();
int result=stmt.executeUpdate("Insert into emp values(3,'david',33) ");
System.out.println("success");
c.close();
} catch(Exception e) {
System.out.println(e);
}
}
}
是 c.createStatement()
而不是 c.CreateStatement()
。
您需要将方法名称中的 c
设为小写 createStatement()