import java.sql.*;
public class Consulta{
public static void main(String agrs[])
{
try{
Class.forName("jdbc6.5-1.2.Driver");
Connection conexion =
DriverManager.getConnection("jdbc:jdbc6.5-1.2//localhost:5432/clientes");
Statement orden = conexion.createStatement();
ResultSet resultado = orden.executeQuery("SELECT
* FROM pedidos");
resultado.next();
System.out.println(resultado.getString(2));
resultado.close();
orden.close();
conexion.close();
} catch (ClassNotFoundException e){
System.out.println("Controlador no
encontrado: " + e);
} catch (SQLException e){
System.out.println("Excepcion SQL: " +
e);
}
}
}
The compiler does not give any error but when sending the interpreter
java I obtain the following thing:
# java Consulta.class
java.lang.NoClassDefFoundError: Consulta/class
at java.lang.Throwable.<init>(Throwable.java:38)
at java.lang.Error.<init>(Error.java:21)
at java.lang.LinkageError.<init>(LinkageError.java:21)
at
java.lang.NoClassDefFoundError.<init>(NoClassDefFoundError.java:21)
¿Why?
--
----------------
ESware Linux
www.esware.com
----------------
Maybe I'm missing the point, but you have to start your application
with "java Consulta" (without the .class). Hope that helps...
Ciao Alex
One problem is the name of the driver. I believe it should be
postgresql.Driver. Put the driver's jar file in your classpath, and refer
to it by this other name. Look in the JDBC examples for the exact name.
You probably want to consider upgrading to the latest version of
postgreslq. It has a lot of new features and is a significant advance over
what you have. In that version, you refer to the JDBC driver as
org.postgresql.Driver.
----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------
> Hello:
> Class.forName("jdbc6.5-1.2.Driver");
> java.lang.NoClassDefFoundError.<init>(NoClassDefFoundError.java:21)
> Javi Roman wrote:
>
> One problem is the name of the driver. I believe it should be
> postgresql.Driver. Put the driver's jar file in your classpath, and refer
> to it by this other name. Look in the JDBC examples for the exact name.
>
Agreed. also, the protocol string should look like
jdbc:postgresql://localhost:5432/clientes
rather than
> jdbc:jdbc6.5-1.2//localhost:5432/clientes
> Class.forName("jdbc6.5-1.2.Driver");
Should be "postgresql.Driver", or "org.postgresql.Driver" for
version 7.0. You also need to have jdbc6.5-1.2.jar in your
class path.
>DriverManager.getConnection("jdbc:jdbc6.5-1.2//localhost:5432/clientes");
Should be "jdbc:postgresql://localhost:5432/clientes"
(though I think that ":5432" can be left out because it is the
default port for PgSQL).
># java Consulta.class
Should be "java Consulta" without ".class";
>java.lang.NoClassDefFoundError: Consulta/class
So it's looking for a class named "class" in a package named
"Consulta".
--
Timo.Ra...@iki.fi
Help keep Usenet clean: <URL: http://www.hut.fi/u/jkorpela/usenet/dont.html >
--Lamine.
On Wed, 23 Aug 2000 10:01:41 -0500, Travis Bauer <trb...@indiana.edu>
wrote:
>Javi Roman wrote:
>
>One problem is the name of the driver. I believe it should be
>postgresql.Driver. Put the driver's jar file in your classpath, and refer
>to it by this other name. Look in the JDBC examples for the exact name.
>