pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedJDBC INSERT Problem
3+ messages / 2 participants
[nested] [flat]
* JDBC INSERT Problem
@ 2005-05-13 00:07 hiuguis@iteso.mx
2005-05-13 00:22 ` Re: JDBC INSERT Problem Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 3+ messages in thread
From: hiuguis@iteso.mx @ 2005-05-13 00:07 UTC (permalink / raw)
To: pgsql-jdbc
Hi to everyone.
Im new with PostgreSQL. Im migrating an SQLServer DB to PostgreSQL and Im having
some problems with insertions. The problem consist only with the SQL INSERT
function via the JDBC driver. When I try to insert some data to some table It
seems that everithing its working fine, but I cannot see the new data in the
table. In the other hand, when I use the SQL Editor from PGAdmin3 it works fine
the same statement.
The other SQL functions like SELECT work fine with the same JDBC so my problem
is only with INSERT.
Please help, because I dont know what Im doing Wrong and Im not receiving any
error messages of any kind. My application is an WEB Based one and I am using
the following:
Linux White Box 3.0 Resping 1
SDK Java 1.4.2
Tomcat 4.1.31
Apache 2.0
mod_jk 1.2
PostgreSQL 8.1
postgresql-8.1dev-400.jdbc3.jar (Downloaded from Postgresql.org)
My DB is coded with LATIN1
The tomcat logs doesnt show any errors
The PostgreSQL logs doesnt show any errors
My application doesnt crash
All my tests done with postgres account.
This is my Stored Procedure
-----------------------------
CREATE OR REPLACE FUNCTION guardavisita(int4, int4, "varchar", "varchar",
"varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar",
"varchar", "varchar", "varchar", "varchar")
RETURNS int4 AS
$BODY$DECLARE
v_idproducto ALIAS FOR $1;
v_tipo ALIAS FOR $2;
v_http_ip ALIAS FOR $3;
v_http_host ALIAS FOR $4;
v_http_tamanocont ALIAS FOR $5;
v_http_mime ALIAS FOR $6;
v_http_path ALIAS FOR $7;
v_http_metodo ALIAS FOR $8;
v_http_srvltpath ALIAS FOR $9;
v_http_nombresrv ALIAS FOR $10;
v_http_puerto ALIAS FOR $11;
v_http_protocolo ALIAS FOR $12;
v_http_sesionid ALIAS FOR $13;
v_http_url ALIAS FOR $14;
v_http_pais ALIAS FOR $15;
BEGIN
INSERT INTO visitas (fechahora, idprod, tipo, http_ip, http_host,
http_tamanocont, http_mime, http_path, http_metodo, http_srvltpath,
http_nombresrv, http_puerto,http_protocolo, http_sesionid, http_url, http_pais)
VALUES (CURRENT_DATE, v_idproducto, v_tipo, v_http_ip, v_http_host,
v_http_tamanocont, v_http_mime, v_http_path, v_http_metodo, v_http_srvltpath,
v_http_nombresrv, v_http_puerto, v_http_protocolo, v_http_sesionid, v_http_url,
v_http_pais);
RETURN 0;
END;$BODY$
LANGUAGE 'plpgsql' STABLE;
ALTER FUNCTION guardavisita(int4, int4, "varchar", "varchar", "varchar",
"varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar",
"varchar", "varchar", "varchar") OWNER TO postgres;
-----------------------------
This is the way I call it
-----------------------------
try
{
Connection conexion = poolDeConexion.getConnection();
try
{
CallableStatement cs = conexion.prepareCall("{? = call
guardavisita(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
cs.registerOutParameter(1, Types.INTEGER);
cs.setInt(2, iIDProducto);
cs.setInt(3, Tipo);
cs.setString(4, http_IP);
cs.setString(5, http_Host);
cs.setString(6, http_TamanoCont);
cs.setString(7, http_MIME);
cs.setString(8, http_Path);
cs.setString(9, http_Metodo);
cs.setString(10, http_SrvltPath);
cs.setString(11, http_NombreSrv);
cs.setString(12, http_Puerto);
cs.setString(13, http_Protocolo);
cs.setString(14, http_SesionID);
cs.setString(15, http_URL);
cs.setString(16, http_Pais);
cs.execute();
respuesta = cs.getInt(1);
System.out.println("The SP answer = " + respuesta); //This always is 0
cs.close();
poolDeConexion.free(conexion);
}
catch(SQLException sqle)
{
System.out.println("Some message : " + sqle.getErrorCode() + "->" + sqle);
}
}
catch(Exception e)
{
System.err.println("Some message : " + e );
}
-----------------------------
Thanks in advance.
Hugo Maldonado
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: JDBC INSERT Problem
2005-05-13 00:07 JDBC INSERT Problem hiuguis@iteso.mx
@ 2005-05-13 00:22 ` Oliver Jowett <oliver@opencloud.com>
2005-05-13 00:42 ` Re: JDBC INSERT Problem hiuguis@iteso.mx
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Jowett @ 2005-05-13 00:22 UTC (permalink / raw)
To: hiuguis@iteso.mx; +Cc: pgsql-jdbc
hiuguis@iteso.mx wrote:
> Im new with PostgreSQL. Im migrating an SQLServer DB to PostgreSQL and Im having
> some problems with insertions. The problem consist only with the SQL INSERT
> function via the JDBC driver. When I try to insert some data to some table It
> seems that everithing its working fine, but I cannot see the new data in the
> table.
Perhaps your connection pool is giving you a connection with autocommit
off. Your code does not commit the transaction containing the INSERT,
and presumably when you return the connection to the pool it is rolling
back the uncommitted transaction.
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: JDBC INSERT Problem
2005-05-13 00:07 JDBC INSERT Problem hiuguis@iteso.mx
2005-05-13 00:22 ` Re: JDBC INSERT Problem Oliver Jowett <oliver@opencloud.com>
@ 2005-05-13 00:42 ` hiuguis@iteso.mx
0 siblings, 0 replies; 3+ messages in thread
From: hiuguis@iteso.mx @ 2005-05-13 00:42 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; pgsql-jdbc
Thank you very much Oliver. Now its working fine even for bytea fields.
Regards.
Mensaje citado por Oliver Jowett <oliver@opencloud.com>:
> hiuguis@iteso.mx wrote:
>
> > Im new with PostgreSQL. Im migrating an SQLServer DB to PostgreSQL and Im
> having
> > some problems with insertions. The problem consist only with the SQL INSERT
> > function via the JDBC driver. When I try to insert some data to some table
> It
> > seems that everithing its working fine, but I cannot see the new data in
> the
> > table.
>
> Perhaps your connection pool is giving you a connection with autocommit
> off. Your code does not commit the transaction containing the INSERT,
> and presumably when you return the connection to the pool it is rolling
> back the uncommitted transaction.
>
> -O
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-05-13 00:42 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-13 00:07 JDBC INSERT Problem hiuguis@iteso.mx
2005-05-13 00:22 ` Oliver Jowett <oliver@opencloud.com>
2005-05-13 00:42 ` hiuguis@iteso.mx
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