No more nonsense, rt~.
First look at the data in the database:
Here is the code for the Java Test class:
Package Com.wl.test;import Java.sql.connection;import Java.sql.drivermanager;import java.sql.resultset;import Java.sql.resultsetmetadata;import Java.sql.statement;public class Test {public static void main (string[] args) {try { Class.forName ("Org.postgresql.Driver"). newinstance (); String url = "Jdbc:postgresql://localhost:5432/testdb"; Connection con = drivermanager.getconnection (URL, "Postgres", "111111"); Statement st = Con.createstatement (); String sql = "SELECT * from T_user"; ResultSet rs = st.executequery (SQL); ResultSetMetaData RSMD = Rs.getmetadata (), int columnCount = Rsmd.getcolumncount (), while (Rs.next ()) {for (int i = 1; I < ; = ColumnCount; i++) {System.out.print (rs.getstring (i) + "\ T");} System.out.println ();} Rs.close (); St.close (); Con.close ();} catch (Exception e) {System.out.print ("Exception:" + e.getmessage ());}}}
The above code is tested for normal, and finally the Maven dependency fragment of PostgreSQL 9.3 is posted:
<!--PostgreSQL--><dependency><groupid>org.postgresql</groupid><artifactid> Postgresql</artifactid><version>9.3-1102-jdbc4</version></dependency>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JDBC Connect PostgreSQL