- 论坛徽章:
- 0
|
回复 1楼 xiaobo_ 的帖子
一、可导入的JSP文件:
<%@ page import="java.sql.*"%>
<%
String dbURL = "jdbc:postgresql://127.0.0.1:5432/MIS";
String userName = "psqldbXXXX";
String passWord = "psqldbXXXX";
Class.forName("org.postgresql.Driver");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{
conn = DriverManager.getConnection(dbURL,userName,passWord);
stmt = conn.createStatement();
}
catch(SQLException sqle)
{
out.println("数据库连接失败!\n错误信息:"+sqle);
}
%>
二、可配置的数据源连接
<!-- pSQL -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>org.postgresql.Driver</value>
</property>
<property name="url">
<value>jdbc:postgresql://127.0.0.1:5432/MIS</value>
</property>
<property name="username">
<value>psqldbXXXX</value>
</property>
<property name="password">
<value>psqldbXXXX</value>
</property>
</bean>
[ 本帖最后由 aoeiu 于 2006-7-12 13:35 编辑 ] |
|