Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection between Java and MYSQL server
- package enceladus.db;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class JDBCTest{
- private Connection conn = null;
- public void connect(){
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- System.out.println("test");
- conn = DriverManager.getConnection("jdbc:mysql://mysql.agh.edu.pl:3306/sadecki","sadecki","top_secret_password");
- System.out.println("test2");
- } catch (SQLException ex) {
- // handle any errors
- System.out.println("SQLException: " ex.getMessage());
- System.out.println("SQLState: " ex.getSQLState());
- System.out.println("VendorError: " ex.getErrorCode());
- }catch(Exception e){e.printStackTrace();}
- }
- test
- SQLException: Communications link failure
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
- SQLState: 08S01
- VendorError: 0
- conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/sadecki","sadecki","top_secret_password");
Add Comment
Please, Sign In to add comment