Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. //establishing MYSQL connection
  2.         Connection conn = null;
  3.         try {
  4.            
  5.             conn = DriverManager.getConnection("jdbc:mysql://192.168.0.151/" + mysql_db, mysql_usr, mysql_pwd);
  6.         } catch (SQLException ex) {
  7.             System.out.println("SQLException: " + ex.getMessage());
  8.             System.out.println("SQLState: " + ex.getSQLState());
  9.             System.out.println("VendorError: " + ex.getErrorCode());
  10.         }
  11.         finally {      
  12.         //MYSQL query
  13.         Statement stmt = null;
  14.         ResultSet rs = null;
  15.         Array arResult = null;
  16.        
  17.         try {
  18.             stmt = conn.createStatement();
  19.             rs = stmt.executeQuery("SELECT * FROM panp_source");
  20.            
  21.             arResult = rs.getArray("url");
  22.            
  23.         } catch (SQLException ex) {
  24.             System.out.println("SQLException: " + ex.getMessage());
  25.             System.out.println("SQLState: " + ex.getSQLState());
  26.             System.out.println("VendorError: " + ex.getErrorCode());
  27.         }
  28.         finally {
  29.             if (rs != null)
  30.                 rs.close();
  31.             if (stmt != null)
  32.                 stmt.close();
  33.         }
  34.        
  35.         System.out.print(arResult.toString());
  36.         if (conn != null)
  37.             conn.close();
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement