Guest User

Untitled

a guest
Aug 24th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public static Connection ConnectionObj = null;
  2. public static Statement SqlStatement = null;
  3. public static ResultSet Sqlresult = null;
  4. public static ResultSetMetaData MetaData = null;
  5. public static String query = "Select * from Wallet";
  6. public static String url = "jdbc:derby://localhost:1527/Database";
  7. public static String user = "ABM";
  8. public static String pass = "password2";
  9.  
  10. public static void main(String[] args) {
  11.  
  12. try {
  13. //Allows you to connect the database
  14. ConnectionObj = DriverManager.getConnection(url, user, pass);
  15. SqlStatement = ConnectionObj.createStatement();
  16. Sqlresult = SqlStatement.executeQuery(query);
  17. MetaData = Sqlresult.getMetaData();
  18. System.out.println("Connection worked");
  19. } catch (SQLException e) {
  20. System.err.println("Got an exception! ");
  21. System.err.println(e.getMessage());
  22. }
  23.  
  24. }
  25.  
  26. <dependencies>
  27. <dependency>
  28. <groupId>mysql</groupId>
  29. <artifactId>mysql-connector-java</artifactId>
  30. <version>5.1.47</version>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.apache.derby</groupId>
  34. <artifactId>derby</artifactId>
  35. <version>10.14.1.0</version>
  36.  
  37. </dependency>
Add Comment
Please, Sign In to add comment