国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

JSP連接各類數據庫大全(下)

2024-09-05 00:19:04
字體:
來源:轉載
供稿:網友
四、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>(代碼實驗室)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 府谷县| 读书| 白城市| 湖州市| 武陟县| 读书| 来宾市| 和田县| 江西省| 伽师县| 西城区| 大连市| 德州市| 鹰潭市| 芜湖县| 武邑县| 海林市| 晋州市| 甘南县| 石楼县| 横山县| 酒泉市| 明水县| 泸溪县| 峨眉山市| 灌南县| 天台县| 都昌县| 邹城市| 永仁县| 勐海县| 新源县| 高安市| 繁昌县| 台湾省| 柳州市| 施秉县| 同德县| 郑州市| 玉门市| 平安县|