早教吧 育儿知识 作业答案 考试题库 百科 知识分享

Statementstmt=conn.createStatement();报错Typemismatch:cannotconvertfromjava.sql.Statementtojava.beans.Statement这个怎么解决啊?程序是packagefirst;importjava.beans.Statement;importjava.sql.Connection;importjava.sql.Driver

题目详情
Statement stmt=conn.createStatement();报错Type mismatch: cannot convert from java.sql.Statement to java.beans.Statement 这个怎么解决啊?程序是 package first; import java.beans.Statement; import java.sql.Connection; import java.sql.DriverManager; public class JDBCtest1 { public static void main(String[] args) { Class .forName("com.mysql.jdbc.Driver"); Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbc","root","admin"); Statement stmt=conn.createStatement(); String sql="insert into student values(1,'Tom',21)"; int row=stmt.executeUpdata(sql); System.out.println("数据库中更新了"+row+"条数据"); stmt.close(); conn.close(); } catch (Exception e) { System.out.prlntln("数据库操作过程发生异常"); // TODO: handle exception } }
▼优质解答
答案和解析
import java.sql.Statement;