Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1.  
  2. import java.sql.*;
  3. public class EvenMoreQuerys {
  4.  
  5.     public static void main(String[] args) {
  6.         try {  
  7.         Class.forName("com.mysql.jdbc.Driver");
  8.         } catch (Exception f) {
  9.             System.out.println("Can't load MySQL driver, exiting...");  
  10.             System.exit(-1);  
  11.         }      
  12.        
  13. final String dbURL = "jdbc:mysql://slo.swe.fh-luebeck.de:3306/Di2a";
  14. final String user ="Di2a";
  15. final String password = "CRFANe42c5mfxzD2";
  16.  
  17. String x = "Mid";
  18.  
  19. try {
  20.         Connection con = DriverManager.getConnection(dbURL, user, password);
  21.         CallableStatement cs = con.prepareCall("{call LaneNicks(?)}");
  22.         ResultSet rs = cs.executeQuery();
  23.  
  24.         while(rs.next()) {
  25.             String name = rs.getString("Name");
  26.            
  27.             System.out.print(name + ", ");
  28.         }
  29.  
  30.     //System.out.println("Success");
  31.  
  32.    
  33. } catch (SQLException ex) {
  34.         System.out.println("statement failed");
  35.         System.out.println("SQLException: " + ex.getMessage());
  36.         System.out.println("SQLState: " + ex.getSQLState());
  37.         System.out.println("VendorError: " + ex.getErrorCode());
  38.  
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement