JSP連接各類數(shù)據(jù)庫大全(4)
發(fā)表時(shí)間:2024-06-07 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]四、jsp連接Informix數(shù)據(jù)庫 testinformix.jsp如下: <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*&qu...
四、jsp連接Informix數(shù)據(jù)庫 testinformix.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword";
//testDB為你的數(shù)據(jù)庫名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一個(gè)字段內(nèi)容為:<%=rs.getString(1)%>
您的第二個(gè)字段內(nèi)容為:<%=rs.getString(2)%>
<%}%>
<%out.print("數(shù)據(jù)庫操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>