Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tutorial {
- static String bd = "Tutorial";
- static String login = "root";
- static String password = "1234";
- static String url = "jdbc:mysql://localhost/";
- public static void main(String[] args) throws InstantiationException, IllegalAccessException {
- Connection conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- conn = DriverManager.getConnection(url,login,password);
- if (conn != null) {
- System.out.println("Conexión a base de datos "+url+" ... Ok");
- conn.close();
- }
- }
- catch(SQLException ex) {
- System.out.println("Hubo un problema al intentar conectarse con la base de datos "+url);
- }
- catch(ClassNotFoundException ex) {
- System.out.println(ex);
- }
- }
- }
Add Comment
Please, Sign In to add comment