Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class TestClient {
  2. static Connection dbConnection = null;
  3. public static void main(String[] args) throws ClassNotFoundException {
  4. try {
  5. Class.forName("org.firebirdsql.jdbc.FBDriver");
  6. String dbURL = "jdbc:firebirdsql://127.0.0.1:3050/C:\databases2\TESTDB.FDB";
  7. String user = "sysdba";
  8. String password = "masterkey";
  9.  
  10. dbConnection = DriverManager.getConnection(dbURL,user, password);
  11. dbConnection.setAutoCommit(false);
  12. PreparedStatement stmt = dbConnection.prepareStatement("SELECT * FROM test_table");
  13. ResultSet rs = stmt.executeQuery();
  14.  
  15. int j = 0;
  16. int i = 0;
  17. String s = "";
  18. while (rs.next()) {
  19. i++;
  20. j = rs.getInt("id");
  21. s = rs.getString("text_col");
  22. }
  23. System.out.println(String.format("Finished reading %d rows.", i));
  24. rs.close();
  25. stmt.close();
  26. dbConnection.close();
  27. } catch (SQLException ex) {
  28. ex.printStackTrace();
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement