Código:
public class conector { public Connection conexion; public String error; public Statement instruccion; String host="localhost", user="user", pass="pass",String="estudiantes"; public conector() throws ClassNotFoundException, SQLException{ try{ Class.forName("com.mysql.jdbc.Driver"); // org.gjt.mm.mysql.Driver conexion=DriverManager.getConnection("jdbc:mysql://"+host+":3306/"+bd,user,pass); instruccion = conexion.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); } catch(ClassNotFoundException e){// si no se encuentra el driver error=e.getMessage(); } catch(SQLException e){// si la conexion falla error=e.getMessage(); } } public Connection getConexion(){ return conexion; } public void cierra() throws SQLException{ try{ conexion.close(); } catch(Exception ex){ } } public String Get_error(){ return error; } }