|
|
|
jsp连接各类数据库大全(下) |
|
|
| http://www.iyit.net 日期:2005-11-24 17:27:05 来源:易特网络技术 点击: |
四、jsp连接informix数据库 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为你的数据库名 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()) {%> 您的第一个字段内容为:<%=rs.getstring(1)%> 您的第二个字段内容为:<%=rs.getstring(2)%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html>
五、jsp连接sybase数据库 testmysql.jsp如下: <%@ page contenttype="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("com.sybase.jdbc.sybdriver").newinstance(); string url =" jdbc:sybase:tds:localhost:5007/tsdata"; //tsdata为你的数据库名 properties sysprops = system.getproperties(); sysprops.put("user","userid"); sysprops.put("password","user_password"); connection conn= drivermanager.getconnection(url, sysprops); statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable); string sql="select * from test"; resultset rs=stmt.executequery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getstring(1)%> 您的第二个字段内容为:<%=rs.getstring(2)%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html> 六、jsp连接mysql数据库 testmysql.jsp如下: <%@ page contenttype="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("org.gjt.mm.mysql.driver").newinstance(); string url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useunicode=true&characterencoding=8859_1" //testdb为你的数据库名 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()) {%> 您的第一个字段内容为:<%=rs.getstring(1)%> 您的第二个字段内容为:<%=rs.getstring(2)%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html>七、jsp连接postgresql数据库 testmysql.jsp如下: <%@ page contenttype="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <html> <body> <%class.forname("org.postgresql.driver").newinstance(); string url ="jdbc:postgresql://localhost/soft" //soft为你的数据库名 string user="myuser"; string password="mypassword"; connection conn= drivermanager.getconnection(url,user,password); statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable); string sql="select * from test"; resultset rs=stmt.executequery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getstring(1)%> 您的第二个字段内容为:<%=rs.getstring(2)%> <%}%> <%out.print("数据库操作成功,恭喜你");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html>(代码实验室)
|
上一篇:jsp计数器制作手册
下一篇:jsp连接各类数据库大全(上)
[发送给好友] [打印本页] [关闭窗口] [返回顶部] 转载请注明来源:http://www.iyit.net |
|
| 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 责任编辑: |
投稿作者: 易特网络技术 |
| 信息来源: 易特网络技术 |
录入时间: 2005-11-24 17:27:05 |
| 浏览次数: |
投稿信箱: shtghy@163.com |
|
|
|
|
|