Este es el codigo que estoy usando
Código:
y me da el siguiente error al correrlo con Jcreatorimport java.sql.*; class TestConnection { static String bd = "biblioteca"; static String login = "root"; static String password = "mypass"; static String url = "jdbc:mysql://localhost/"+bd; public static void main(String[] args) throws Exception { 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(ex); } catch(ClassNotFoundException ex) { System.out.println(ex); } } }
Código:
Tengo las Classpath y aun asi no funciona, ojalas pueda recibir alguna ayudajava.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream ** BEGIN NESTED EXCEPTION ** java.io.IOException MESSAGE: Unexpected end of input stream STACKTRACE: java.io.IOException: Unexpected end of input stream at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562) at com.mysql.jdbc.Connection.<init>(Connection.java:491) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at TestConnection.main(TestConnection.java:19) ** END NESTED EXCEPTION ** Process completed.
Saludos ...