conectar a base de datos
Publicado por Charly (118 intervenciones) el 01/03/2017 16:02:22
Hola, estoy creando una aplicacion conectada a una base de datos.
La clase que me da problemas es esta:
Y me aparece el siguiente error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "127.0.0.1"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.tokenizeOptionalPortNumber(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at conexionDDBB.<init>(conexionDDBB.java:11)
at gestorAlumnos.<init>(gestorAlumnos.java:331)
at TestGestorAlumnos.main(TestGestorAlumnos.java:3)
La clase que me da problemas es esta:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.sql.*;
public class conexionDDBB{
private Connection con=null;
public conexionDDBB(){
try{
//Class.forName("com.mysql.jdbc.Driver");
Class.forName("org.apache.derby.jdbc.ClientDriver");
try{
//con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/UNIVERSIDAD","root","");
String sURL="jdbc:derby://localhost:127.0.0.1/UNIVERSIDAD;create=true;user=cdum;password=cdum";
con=DriverManager.getConnection(sURL);
}catch(SQLException e){
e.printStackTrace();
}
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public Connection getConexion(){
return con;
}
public void cerrarConexion(){
try{
con.close();
}catch(SQLException e){
e.printStackTrace();
}
}
}
Exception in thread "main" java.lang.NumberFormatException: For input string: "127.0.0.1"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.tokenizeOptionalPortNumber(Unknown Source)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at conexionDDBB.<init>(conexionDDBB.java:11)
at gestorAlumnos.<init>(gestorAlumnos.java:331)
at TestGestorAlumnos.main(TestGestorAlumnos.java:3)
Valora esta pregunta


0