PDA

View Full Version : [DBMS] Nessuno usa PostgreSQL?!


Matrixbob
12-06-2005, 13:42
... come da titolo. :)

Brazorv
12-06-2005, 16:42
io l'ho usato per l'esame di basi di dati. l'ennesimo progetto di gestione di una biblioteca

Matrixbob
12-06-2005, 17:28
io l'ho usato per l'esame di basi di dati. l'ennesimo progetto di gestione di una biblioteca
Ci hai mai provato ad accedere da scriptlet JSP?!
Come ci accedevi?!

Mi fai un esempio per piacere?!
TNX.

Matrixbob
12-06-2005, 17:30
Io sto cercando di accederci così:

<html>

<head><title>JDBC with Tags - PSQL</title></head>

<body>

<%@ taglib uri="http://jakarta.apache.org/taglibs/taglibs-dbtags" prefix="sql" %>

<sql:connection id="conn1">
<sql:url> jdbc:postgresql://localhost:5432/queryjdbc?user=postgres&password=cane </sql:url>
<sql:driver> org.postgresql.Driver </sql:driver>
</sql:connection>

<table border=1 align="center">

<thead><th>Codice Fiscale </th><th>Nome </th><th>Cognome </th></thead>

<tbody>
<sql:statement id="stm1" conn="conn1">
<sql:query> SELECT * FROM persone </sql:query>

<sql:resultSet id="rs1">
<tr>
<td><sql:getColumn position="1"/></td>
<td><sql:getColumn position="2"/></td>
<td><sql:getColumn position="3"/></td>
</tr>
</sql:resultSet>
</sql:statement>
</tbody>

</table>

<%-- <sql:statement id="ins1" conn="conn1">
<sql:query>
insert into persona values('RLFMRA64D41B741K','Maria','Rossi')
</sql:query>
<sql:execute ignoreErrors="true"/>
</sql:statement>
--%>

<sql:closeConnection conn="conn1"/>

</body>

</html>

Ma il risultato è questo:
http://img168.echo.cx/img168/2818/errpsql5kl.gif

Brazorv
12-06-2005, 17:55
Mi dispiace non l'ho mai usato con java o jsp, ho usato php

Matrixbob
12-06-2005, 18:01
Mi dispiace non l'ho mai usato con java o jsp, ho usato php
Quindi pg_connect e tutte le altre pg_functions?!

Brazorv
12-06-2005, 18:03
si se guardi la documentazione di php ci sono tutte. Una volta installato php e postgres non c'è bisogno di configurare nient'altro mi pare

Dun
12-06-2005, 19:14
Personalmente mai usato i tag <sql>. Era la servlet di inizializzazione che creava un bean che facesse da framework e quindi accettasse le query.

Ti posto come facevo la connessione. Per usarlo nelle jsp penso basti inserire il tutto dentro i tag <% %> e da qui creare tramite l'oggetto conn (tipo Connection) le Statement o le Prepared Statement per cosi fare le query.


try {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://"+this.getDb_home()+":"+this.getDb_port()+"/"+this.getDb_name(),this.getDb_user(),this.getDb_passwd());
conn.setAutoCommit(false);
} catch (ClassNotFoundException cnfe) {
setDebug("!!NOT OK (ClassNotFound): " + cnfe.getMessage());
} catch (SQLException sqle) {
setDebug("!!NOT OK (SQLException): " + sqle.getMessage());
} catch (Exception e) {
setDebug("!!NOT OK (Exception): " + e.getMessage());
}
return true;

Dun
12-06-2005, 19:16
Ricorda che cmq una volta connessi al server tramite jdbc (hai utilizzato il driver jdbc per postgres? lo trovi su jdbc.postgresql.org mi pare) l'utilizzo del dbms a meno di funzioni nn standard e pressocche' uguale a qsiasi dbms

Matrixbob
12-06-2005, 20:26
Ricorda che cmq una volta connessi al server tramite jdbc (hai utilizzato il driver jdbc per postgres? lo trovi su jdbc.postgresql.org mi pare) l'utilizzo del dbms a meno di funzioni nn standard e pressocche' uguale a qsiasi dbms
Confermo.
Io il JDBC driver lo ho messo qui:
D:\www\public_html\WEB-INF\lib\postgresql-8.0-311.jdbc3.jar

e lavorando con Tomcat in "lib" della mia applicazione web ci stanno tutti i JAR prodotti da altri.

Il fatto è che a me forse serve il JDBC di tipo 4 e sul sito di PostgreSQL sembra non esistere...
http://img150.echo.cx/img150/5134/43tl.gif
http://img150.echo.cx/img150/2387/13tu.gif
http://img150.echo.cx/img150/5620/26di.gif
http://img150.echo.cx/img150/5743/35je.gif

Dun
12-06-2005, 20:30
Confermo.
Io il JDBC driver lo ho messo qui:
D:\www\public_html\WEB-INF\lib\postgresql-8.0-311.jdbc3.jar

e lavorando con Tomcat in "lib" della mia applicazione web ci stanno tutti i JAR prodotti da altri.

Il fatto è che a me forse serve il JDBC di tipo 4 e sul sito di PostgreSQL sembra non esistere...

Nn sapevo manco eistesse la versione 4 :)

Matrixbob
12-06-2005, 20:42
Nn sapevo manco eistesse la versione 4 :)
Ti faccio vedere un codice pressochè identico, ma dove uso MySQL:

<html>

<head><title>JDBC with Tags - MySQL</title></head>

<body>

<%@ taglib uri="http://jakarta.apache.org/taglibs/dbtags" prefix="sql" %>

<sql:connection id="conn1">
<sql:url> jdbc:mysql://localhost:3306/queryjdbc?user=root&password=cane </sql:url>
<sql:driver> org.gjt.mm.mysql.Driver </sql:driver>
</sql:connection>

<table border=1 align="center">

<thead><th>Codice Fiscale </th><th>Nome </th><th>Cognome </th></thead>

<tbody>
<sql:statement id="stm1" conn="conn1">
<sql:query> SELECT * FROM persone ORDER BY nome </sql:query>

<sql:resultSet id="rs1">
<tr>
<td><sql:getColumn position="1"/></td>
<td><sql:getColumn position="2"/></td>
<td><sql:getColumn position="3"/></td>
</tr>
</sql:resultSet>
</sql:statement>
</tbody>

</table>

<%--
<sql:statement id="ins1" conn="conn1">
<sql:query> INSERT INTO persone VALUES('DDDDDD','Tony','Russo') </sql:query>
<sql:execute ignoreErrors="true"/>
</sql:statement>
--%>

<sql:closeConnection conn="conn1"/>


</body>

</html>


Il cui output è questo:
http://img196.echo.cx/img196/1120/ris1hj.gif

Adesso capisci perchè ci rimango malissimo?! :doh:
Tanto male da giudicare questa tecnologia JDBC-JSTL o DBTAGS "immatura" ... :(

Matrixbob
13-06-2005, 21:02
UP!