Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class TableReader {
- static Connection getConnection() {
- Connection connection = null;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection(
- "jdbc:mysql://184.154.73.113/davidlno_StockHistory?" +
- "user=davidlno_student&password=ez24get!");
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- System.out.println("SQLException: " + e.getMessage());
- System.out.println("SQLState: " + e.getSQLState());
- System.out.println("VendorError: " + e.getErrorCode());
- }
- return connection;
- }
- public static void main(String[] args) {
- Connection connection = getConnection();
- try {
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- connection = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement