select.java
来自「本网站为学生管理网站」· Java 代码 · 共 116 行
JAVA
116 行
package students;
import java.sql.*;
public class Select {
public static void select(String stu,String str1,String str2,String str3,String str4,String str5){
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
if(str1!=null){
try {
con = Database.connectToDb();
String strSQL = "insert into sel_crouses(ID,cro_id,year,degree )"+"value('"+stu+"','"+str1+"','2007','')";
stmt = con.createStatement();
stmt.executeUpdate(strSQL);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
con = null;
}
}
}
if(str2!=null){
try {
con = Database.connectToDb();
String strSQL = "insert into sel_crouses(ID,cro_id,year,degree )"+"value('"+stu+"','"+str2+"','2007','')";
stmt = con.createStatement();
stmt.executeUpdate(strSQL);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
con = null;
}
}
}
if(str3!=null){
try {
con = Database.connectToDb();
String strSQL = "insert into sel_crouses(ID,cro_id,year,degree )"+"value('"+stu+"','"+str3+"','2007','')";
stmt = con.createStatement();
stmt.executeUpdate(strSQL);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
con = null;
}
}
}
if(str4!=null){
try {
con = Database.connectToDb();
String strSQL = "insert into sel_crouses(ID,cro_id,year,degree )"+"value('"+stu+"','"+str4+"','2007','')";
stmt = con.createStatement();
stmt.executeUpdate(strSQL);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
con = null;
}
}
}
if(str5!=null){
try {
con = Database.connectToDb();
String strSQL = "insert into sel_crouses(ID,cro_id,year,degree )"+"value('"+stu+"','"+str5+"','2007','')";
stmt = con.createStatement();
stmt.executeUpdate(strSQL);
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
con = null;
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?