
paboitb
(usa Kurumin)
Enviado em 17/12/2007 - 19:47h
amigo já axei em varios lugares a mesma classe basicamente que é essa logo abiaxo, o roblea eh que comigo não ta funcionando mas ai vai pra vc tentar..
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.postgresql.Driver;
public class PGTest {
public PGTest() throws Exception {
String host = "localhost";
String port = "5432";
String schema = "template1";
String user = "postgres";
String passwd = "postgres";
Driver.class.newInstance();
Connection c = DriverManager.getConnection("jdbc:postgresql://" + host + ":" + port + "/" + schema,
user, passwd);
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT '1' AS VALOR");
while (rs.next()) {
System.out.println(rs.getString("VALOR"));
}
rs.close();
c.close();
}
public static void main(String[] args) {
try {
new PGTest();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
ah lembrando que vc tem baixar o drive ok. falou