-2

我正在尝试将数据插入 MySQL,但出现错误:

找不到符号 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);
        }
    }

}

在此处输入图像描述

4

1 回答 1

-1

c.createStatement()和不是c.CreateStatement()

您需要c在方法名称中将其设为小写createStatement()

于 2015-09-20T13:13:46.877 回答