1
I created a database using the javadb netbeans derby, then created a connection on port 1527 with the name of the Database being TEST. After that, I created the connection string below that should connect me to the TESTE Database, but with the code below I cannot connect.
package javadata;
import java.sql.*;
/**
*
* @author Djafta
*/
public class JavaData {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//PARAMETROS("jdbc:derby://host:port//DB;user=?;password=?");
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:derby://localhost:1527/TESTE","root","root");
System.out.println("Conectado com sucesso...");
} catch (SQLException ex) {
System.out.println("Problema de conexao: " + ex);
}
//Statement sql = conn.createStatement();
}
}
Now you are giving the error asseguir after adding ex.printStackTrace();:
java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/TESTE
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at javadata.JavaData.main(JavaData.java:25)
Does it give any error? If it does not give, try to put
ex.printStackTrace();
in the catch to see if the exception is being captured.– user28595
Now giving the error: java.sql.Sqlexception: No suitable driver found for jdbc:derby://localhost:1527/TESTE
– Djafta
Dafta edits the question by adding the error stack of prinstacktrace, it seems that you can already know the cause.
– user28595
It’s done. I realized it helps in organizing the page
– Djafta
You saw my answer below?
– user28595