postgresql - Postgres : No suitable Driver found for jdbc JAR File -


My eclipse program is working well. However, when I try to compile it in a JAR file, then I get this error:

java.sql.SQLException: no suitable driver was found for jdbc: postgresql: //10.0.0.19: 5432 / Fussballverein

I added the connector to my Java files and exported them to a jar file, is that correct?

This is how my jar file looks:

MyModel.class

MyModel.java

MyControll.class

MyControll.java

Mpanel

mypanel.java

Postgrescle-9.3-1101. jdbc3.jar

Maryframe

When I try to run it from my command prompt, it looks like this:

Java -jar Gebauer_Laurenz.jar 10.0.0.19 User name password fussballverein

I'm already getting the error here is my code; It would be great if someone could help.

  public throws auführen () SQLException, ClassNotFoundException {// Connection Objekt connection con = null; Println (server + "+ db +" "+ user +" + pw); Try {//Class.forName("org.postgresql.Driver "); // After death in DriverManager, Verbindingssten Engtregen then des eine verbundung hogestel verden ears Con = DriverManager.getConnection ("jdbc: postgresql: //" + server + ": 5432 /" + db + "", "" + + "", "" + pw + "");    

There are two possible problems: using the wrong segment, and using a JDBC 3 driver ( driver -class instead of a JDBC4 driver without explicitly loading.

Problem 1: class

Dependent jar of your own jar Should not be included inside, they should be placed next to their own jar and then specified in class-path in MANIFEST.MF .

Should be done eg Your layout for the RAN is:

  your.jar postgresql-9.3-1101.jdbc3.jar   

then MANIFEST.MF Should be an entry for your. :

  class-path: postgrasskie-9.3-1101. Jdbc3.jar   < p> For details see.  

Problem 2: JDBC3 Driver

The driver you are using is a JDBC3 driver. Driver Auto loading only allows JDBC4 (Java 6 ). JDBC 4 works by auto loading drivers Which declares what their driver class (SAS) is, probably a JDBC3 driver does not have that file in your code. class .for name ... has been commented and the driver does not load Will be done.

If you are using Java 6 or more, JDBC 4 Java 6) or JDBC 4.1 (Java 7) drivers.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -