I use the following code to connect to mysql
public static void main(String[] args) {
MapeadorServicio aux = new MapeadorServicio();
Auto aux1 = new Auto(0);
Persistencia p = Persistencia.getInstancia();
p.guardar(aux);
}
public void guardar(Mapeador map){
if(map.getOid()==0) insertar(map);
else modificar(map);
}
private void insertar(Mapeador m) {
int oid = proximoOid();
m.setOid(oid);
ArrayList<String> sqls = m.getSqlInsert();
if (!base.transaccion(sqls)){
m.setOid(0);
}
}
public boolean transaccion(ArrayList<String> sqls){
try {
conexion.setAutoCommit(false); //begin T
for(String sql:sqls){
if(actualizar(sql)==-1){
conexion.rollback();
return false;
}
}
conexion.commit();
return true;
} catch (SQLException ex) {
System.out.println("Error en T:" + ex.getMessage());
return false;
}finally{
try {
conexion.setAutoCommit(true); //end T
} catch (SQLException ex) {
}
}
}
private Persistencia() {
base = BaseDatos.getInstancia();
try {
base.conectar("jdbc:mysql://localhost/AutosYa.com", "root", "root");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, ex);
}
}
The error I have is the following by console
Wed Dec 27 20:15:22 UYT 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option is not set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL = false, or set useSSL = true and provide truststore for server certificate verification. Exception in thread "main" java.lang.NullPointerException Error connecting: Access denied for user 'root' @ 'localhost' (using password: YES) at mapeadores.MapeadorServicio.getOid (MapeadorServicio.java:46) at persistence.Persistence.guard (Persistence.java:58) at autosya.com.AutosYaCom.main (AutosYaCom.java:24) /Users/usuario/Library/Caches/NetBeans/8.2/executor-snippets/run.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)
Error connecting: Access denied for user 'root' @ 'localhost' (using password: YES) at mappers.MappingService.getOid (MappingService.java:46) at
according to my MMAP
Here it looks as if I can enter with those credentials
In my project, import the JAR for the jdbl