Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String hostname;
- private Integer port;
- private String username;
- private String password;
- private String database;
- private Connection connection;
- private Statement statement;
- private ResultSet result;
- try
- {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- }
- catch (Exception ex)
- {
- System.out.println(ex.getMessage());
- }
- try
- {
- this.connection = DriverManager.getConnection("jdbc:mysql://"+ this.getHostname() + "/" + this.getDatabase() + "?" +
- "user="+ this.getUsername() + "&password=" + this.getPassword());
- }
- catch (SQLException ex)
- {
- System.out.println("SQLException: " + ex.getMessage());
- System.out.println("SQLState: " + ex.getSQLState());
- System.out.println("VendorError: " + ex.getErrorCode());
- }
- try
- {
- this.statement = this.connection.createStatement());
- if (this.statement.execute(query))
- {
- this.result = this.statement.getResultSet());
- }
- }
- catch (SQLException ex)
- {
- System.out.print(ex.getMessage());
- }
- finally
- {
- }
Add Comment
Please, Sign In to add comment