Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- Connection conn = null;
- Statement statement = null;
- ResultSet rs = null;
- try{
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- String connectionUrl = "jdbc:sqlserver://<server_name>:1433;databaseName=<db_name>;integratedSecurity=true;user=<user>;password=<***>";
- conn = DriverManager.getConnection(connectionUrl);
- statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
- rs = statement.executeQuery(query1 + itemTag + query2);
- while(rs.next()){
- String number = rs.getString(1);
- tableItem.setText(7, number);
- break;
- }
- }catch (SQLException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }finally {
- if (rs != null) try { rs.close(); } catch(Exception e) {}
- if (statement != null) try { statement.close(); } catch(Exception e) {}
- if (conn != null) try { conn.close(); } catch(Exception e) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement