I cant connect my db with my java aplication and I really dont know whts wrong with it, comeone cant help me, please
try {
Connection miconexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/concesionario","root","password");
// 2.PASO CREAR PASO STAMENT.
Statement miStatement = miconexion.createStatement();
//3.PASO EJECUTAR MY SQL.
ResultSet miresulset = miStatement.executeQuery("SELECT * FROM CLIENTES");
//4.PASO RECORRER EL RESULSET
while(miresulset.next()) {
System.out.println(miresulset.getString("dni" + miresulset.getString("nombre" + "" + miresulset.getString("apellido"))));
}
}catch(Exception e) {
System.out.println("NO CONECTA");
e.printStackTrace();
}
This line
System.out.println(miresulset.getString("dni" + miresulset.getString("nombre" + "" + miresulset.getString("apellido"))));
adds whatever is found as apellido to "nombre". The value happens to be "Garcia", hence the String
of nombreGarcia in the error. This is as far as I can go with helping you without further information from your part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.