JAVA / JDBC

PostgreSQL JDBC Driver (多語系)



JDBC Drivers


TYPE-3
TYPE-4



(分享教學簡報) JDBC 與 PostgreSQL

J2005.Java.JDBC.PostgreSQL‎‎(資料庫連結與PostgreSQL)‎‎





Class - org.postgresql.Driver


Url - jdbc:postgresql://[ IP | FQDN ]:5432/[ DbName ]

ex.
jdbc:postgresql://localhost:5432/kuochaoyidb




Java Types vs PostgreSQL Types




PostgreSQL JDBC線上手冊




JavaWorld@TW - JDBC - PostgreSQL 討論板


防止SQL注入攻擊


客戶端要用 UTF-8 編碼,jdbc url 後面加參數「?charSet=UTF-8」 試試看,比如: jdbc:postgresql://localhost/mydb?charSet=UTF-8

另外,下面這段代碼不好:
thebig 引用 2007-05-16 21:23

Statement stm=conn.createStatement();
ResultSet result=stm.executeQuery("select * from daolumian where daolumian.名稱="+username+"");
return result;

為防止 sql 注入,建議修改為:
代碼

final PreparedStatement stm = con.prepareStatement("select * from daolumian where 名稱=?");
stm.setString(1, username);
return stm.executeQuery();



PostgreSQL JDBC
http://jdbc.postgresql.org/
http://www.fankhausers.com/postgresql/jdbc/
http://man.ddvip.com/database/postgresql-jdbc/index.html


Java SE Technologies - Database
http://java.sun.com/javase/technologies/database/index.jsp

The PostgreSQLJDBC Interface
http://man.ddvip.com/database/postgresql-jdbc/index.html




Comments