this.pstmt=pstmt;
this.rs=rs;
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost/mydatabase?useUnicode=true&characterEncoding=UTF-8";
conn=DriverManager.getConnection(url,"root","root");
pstmt=conn.createStatement();
rs=pstmt.executeQuery("select*from dictionary");
你这里的 this.rs还是null,所以,会抛nullPoint,应该把this.rs=rs; 这句放到rs=pstmt.executeQuery("select*from dictionary");
的后面,
还有,mdd.rs.getString("word")==tfind.getText()这个判断很有问题,String类的判断,这里最好用
mdd.rs.getString("word".equals(tfind.getText());
Java使用MySQL
最新推荐文章于 2024-05-28 13:51:00 发布