public ListgetCatalogs(){
List lists = new ArrayList<>();
Connection connection=Dbuitl.getConnection();
String sql= "select catalog from catalogs";
PreparedStatement preparedStatement= null;
ResultSet resultSet= null;try{
Statement statement=connection.createStatement();
resultSet=statement.executeQuery(sql);while(resultSet.next()) {
lists.add(resultSet.getString("catalog"));
}
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}finally{
Dbuitl.close(preparedStatement);
Dbuitl.close(connection);
}returnlists;
}public voidinsert(String type,String cata) {
Connection connection=Dbuitl.getConnection();
String sql= "insert into catalogs(type,catalog) value(?,?)";
PreparedStatement preparedStatement= null;
ResultSet resultSet= null;try{
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1, type);
preparedStatement.setString(2, cata);
preparedStatement.executeUpdate();
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}finally{
Dbuitl.close(preparedStatement);
Dbuitl.close(connection);
}
}public voidinsertContext(String catalog,String context) {
Connection connection=Dbuitl.getConnection();
String sql= "insert into context(catalog,context) value(?,?)";
PreparedStatement preparedStatement= null;
ResultSet resultSet= null;try{
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1, catalog);
preparedStatement.setString(2, context);
preparedStatement.executeUpdate();
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}finally{
Dbuitl.close(preparedStatement);
Dbuitl.close(connection);
}
}public voidinsertSheet(String sheet,String type) {
Connection connection=Dbuitl.getConnection();
String sql= "insert into sheet(sheet,type) value(?,?)";
PreparedStatement preparedStatement= null;
ResultSet resultSet= null;try{
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1, sheet);
preparedStatement.setString(2, type);
preparedStatement.executeUpdate();
}catch(SQLException e) {//TODO Auto-generated catch block
e.printStackTrace();
}finally{
Dbuitl.close(preparedStatement);
Dbuitl.close(connection);
}
}