level 5
357339848
楼主
public void update(String name,Integer id){
Connection conn = null;
Statement stmt = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jiaoyu?user=root&password=123456");
stmt = conn.createStatement();
String sql = "update to_techer set touxiang ='变量name' where id='变量id'";
stmt.executeUpdate(sql);
}catch(Exception e){
e.printStackTrace();
}finally{
try {
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
怎么把上面的name和id用到变量name和变量id那里呢?
2015年08月12日 07点08分
1
Connection conn = null;
Statement stmt = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jiaoyu?user=root&password=123456");
stmt = conn.createStatement();
String sql = "update to_techer set touxiang ='变量name' where id='变量id'";
stmt.executeUpdate(sql);
}catch(Exception e){
e.printStackTrace();
}finally{
try {
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
怎么把上面的name和id用到变量name和变量id那里呢?