pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feeda big question
2+ messages / 2 participants
[nested] [flat]
* a big question
@ 2004-05-20 22:54 Dam Avalos <aleidam8@yahoo.com>
0 siblings, 1 reply; 2+ messages in thread
From: Dam Avalos @ 2004-05-20 22:54 UTC (permalink / raw)
To: pgsql-jdbc
Hi!
I have a big problem with the postgress driver, and i hope you can help me, i´m programming with java, and java has a method name Class.forName() that ask for the postgress driver... I send you the archive ConexionBD.java, and i hope you can help me, because when i run the program it says that it can´t get the driver, or found the driver, or something like that, so, well if you can help me i´ll be very gratefull with you, thanks a lot
/*
ARCHIVO: ConexionBD.java
AUTOR: Daniela Avalos Monroy
aleidam8@yahoo.com
Programa que hace una conexion a Base de Datos
realizada en postgress por medio de codigo en
Java*/
package libro.src;
import java.sql.*;
import java.net.URL;
public class ConexionBD
{
//Los datos de configuracion
static String URL = "jdbc:postgresql://ada.fciencias.unam.mx/libroo";//Nombre de la base de datos.
static String USER = "davalosm";
static String PASSWD = "";
Connection con = null;
Statement stmt=null;
public ConexionBD()
{}
/**Esta funcion establece una conexion a la BD.*/
public void openConexion()
{
System.out.println(" Estableciendo conexion...");
try
{
//Class.forName("postgresql.Driver"); //Cualquiera de los 2 funciona.
Class.forName("org.postgresql.Driver"); //Cualquiera de los 2 funciona.
}
catch(Exception e)
{
System.out.println("No se puede cargar el driver de psql.");
}
System.out.println("Driver de psql cargado con exito...!!!.");
try
{
con = DriverManager.getConnection(URL, USER, PASSWD);
System.out.println("Conexion establecida...");
}
catch( Exception e)
{
e.printStackTrace();
}
}
/*Esta funcion cierra la conexion*/
public void closeConexion()
{
try
{
con.close();
System.out.println("Conexion cerrada...");
}
catch( Exception e)
{
e.printStackTrace();
System.out.println("Error al cerrar la conexion...");
}
}
/*Esta funcion cierra la conexion*/
public void closeStatement()
{
try
{
stmt.close();
System.out.println("Statement cerrado...");
}
catch( Exception e)
{
e.printStackTrace();
System.out.println("Error al cerrar el statement...");
}
}
/**Esta funcion nos permite ejecutar una consulta de tipo Update*/
public void executeUpdate(String _Update)
{
try
{
stmt = con.createStatement();
System.out.println("Creamos el statement...");
stmt.executeUpdate(_Update);
System.out.println("Executamos el update...");
//stmt.close();
System.out.println("Cerramos el statement...");
}
catch( Exception e)
{
e.printStackTrace();
System.out.println("Error al cerrar el statement...");
closeStatement();
closeConexion();
}
}
/** Eejecuta una consulta */
public ResultSet executeQuery(String _Query)
{
ResultSet rs = null;
Statement stmt;
try{
stmt = con.createStatement();
System.out.println("Creamos el statement...");
rs = stmt.executeQuery(_Query);
System.out.println("Executamos el Query...y almacenamos en el ResutlSet");
//stmt.close();
System.out.println("Cerramos el statement...");
}
catch( Exception e)
{
e.printStackTrace();
System.out.println("Error al cerrar el statement...");
closeStatement();
closeConexion();
}
return rs;
}
}
/*Fin de archivo ConexionBD.java*/
---------------------------------
Do you Yahoo!?
Yahoo! Domains - Claim yours for only $14.70/year
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: a big question
@ 2004-05-21 07:58 Oliver Jowett <oliver@opencloud.com>
parent: Dam Avalos <aleidam8@yahoo.com>
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Jowett @ 2004-05-21 07:58 UTC (permalink / raw)
To: Dam Avalos <aleidam8@yahoo.com>; +Cc: pgsql-jdbc
Dam Avalos wrote:
> Hi!
> I have a big problem with the postgress driver, and i hope you can help
> me, i´m programming with java, and java has a method name
> Class.forName() that ask for the postgress driver... I send you the
> archive ConexionBD.java, and i hope you can help me, because when i run
> the program it says that it can´t get the driver, or found the driver,
> or something like that, so, well if you can help me i´ll be very
> gratefull with you, thanks a lot
Without more detail it's hard to be sure, but the most likely problem is
that the PostgreSQL JDBC driver is not in your classpath. See
http://www.postgresql.org/docs/7.4/static/jdbc.html#JDBC-CLASSPATH
-O
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-05-21 07:58 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-05-20 22:54 a big question Dam Avalos <aleidam8@yahoo.com>
2004-05-21 07:58 ` Oliver Jowett <oliver@opencloud.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox