From: | Franco Bruno Borghesi <fborghesi(at)gmail(dot)com> |
---|---|
To: | "boleguy(at)adinet(dot)com(dot)uy" <boleguy(at)adinet(dot)com(dot)uy> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: java.sql.SQLException: No suitable driver |
Date: | 2005-05-10 17:38:08 |
Message-ID: | e13c14ec050510103846db6b0e@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
ok, but you don't need to shout! :P
Two things:
1)have you added your jar to the project's java build path? (if you did, go
to the second) right click on the project name, select Properties, go to Java
Build Path, go to the Libraries tab, click Add External Jars and find your
pgxxxxxxxxxx.jar
2) be sure to load the driver first doing a Class.forName("
org.postgresql.Driver"); in your code. Also check your url, it should be
"jdbc:postgresql://172.16.100.110:5432/benjamin"
If it works, have a mate for me ;-)
2005/5/10, boleguy(at)adinet(dot)com(dot)uy <boleguy(at)adinet(dot)com(dot)uy>:
>
> HI:
> I'M TRYING TO CONNECT AN ECLIPSE 3.01 IDE RUNNING ON WINDOWS XP WITH A DB
> POSTGRESQL VERSION 7.4.7. I USED THE FOLLOWINGS DRIVERS: PG.74.213
> /4/5/6.JDBC3.JAR
> AND NO ONE WORKS.
>
> THE MESSAGE WAS THE FOLLOWING:
> Cargando clase
> IWAV0055I Java Bean frenchconn.connpost started with the main method
> java.sql.SQLException: No suitable driver
> at java.sql.DriverManager.getConnection(Unknown Source)
> at java.sql.DriverManager.getConnection(Unknown Source)
> at frenchconn.connpost.agregarCliente(connpost.java:33)
> at frenchconn.connpost.main(connpost.java:69)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(
> JavaBeansLauncher.java:86)
>
> AND THE CODE (MY CODE):
>
> import java.sql.*;
> import java.sql.DriverManager;
> import java.sql.PreparedStatement;
>
> //import samples.jdbc.JDBCTest;
>
> /**
> * @author Benjamin
> *
> * TODO To change the template for this generated type comment go to
> * Window - Preferences - Java - Code Style - Code Templates
> */
> public class connpost {
>
> static {
> System.out.println("Cargando clase");
> }
>
> public void agregarCliente(long idCliente,
> String nombre) {
> try {
> String url = "jdbc:postgres://172.16.100.110:5432/benjamin";
> Connection conn = null;
> conn = DriverManager.getConnection(url,"benjamin", "benja1");
> DriverManager.getDriver("org.postgresql.Driver");
>
> String sql =
> "INSERT INTO Cliente " +
> "(IdCliente, Nombre) " +
> "VALUES (?,?)";
>
> PreparedStatement ps =
> conn.prepareStatement(sql);
>
> ps.setLong(1, idCliente);
> ps.setString(2, nombre);
>
> ps.executeUpdate();
>
> ps.close();
>
> conn.close();
>
> System.out.println("Cliente insertado OK");
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> }
>
> public static void main(String[] args) {
>
> try {
> // Cargo el driver JDBC de postgres
> Class.forName("org.postgresql.Driver");
>
> connpost conn = new connpost();
> //jdbcTest.agregarCliente(1, "Pepe");
> //jdbcTest.agregarCliente(2, "Juan");
> conn.agregarCliente(123,"pepe");
>
> // jdbcTest.transaccion();
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> }
> }
>
> THANKS FOR EVERYTHING TO ANYONE
>
> BENJAMIN
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2005-05-11 07:42:20 | Re: Translation update: pt_BR |
Previous Message | Nelson Arapé | 2005-05-10 17:32:38 | Re: java.sql.SQLException: No suitable driver |