java语言基础代码字典 java字典用法( 五 )


}
url = "jdbc:odbc:test";
}
public String jupdate(String str1,String str2) {
try {
con = DriverManager.getConnection(url);
sql = "UPDATE 字典 SET 词语解释=? WHERE 单词=?";
pstmt= con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
pstmt.setString(1,str1);
pstmt.setString(2,str2);
pstmt.executeUpdate();
Statement s = con.createStatement();
sql1 = "SELECT * FROM 字典 ";
rs = s.executeQuery(sql1);
while (rs.next()) {
System.out.print(rs.getString(1));
System.out.print(rs.getString(2));
System.out.println(" ");
}
rs.close();
pstmt.close();
con.close();
} catch (SQLException ce) {
System.out.println(ce);}
return zz;
}
}
//删除类
class delete {
private Connection con;
private String url;
private PreparedStatement pstmt;
private String sql,sql1,zz;
private ResultSet rs;
delete() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ce) {
System.out.println(ce);
}
url = "jdbc:odbc:test";
}
public String jdelete(String str1) {
try {
con = DriverManager.getConnection(url);
sql = "delete 字典 WHERE 单词=?";
pstmt= con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
pstmt.setString(1,str1);
pstmt.executeUpdate();
Statement s = con.createStatement();
sql1 = "SELECT * FROM 字典 ";
rs = s.executeQuery(sql1);
while (rs.next()) {
System.out.print(rs.getString(1));
System.out.print(rs.getString(2));
System.out.println(" ");
}
rs.close();
pstmt.close();
con.close();
} catch (SQLException ce) {
System.out.println(ce);}
return zz;
}
}
还有个数据库,如果你能留个邮箱,我把整份程序传给你~希望能帮到你
【java语言基础代码字典 java字典用法】关于java语言基础代码字典和java字典用法的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读