| |
| ★jsp连接mysql数据库大全★ |
| |
发布者: 发布时间:2007-01-27 |
|
|
|
现在开始我们的jsp和数据库之旅吧! ●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>
|
| (转载文章请保留出处:北天JAVA技术网(www.java114.com)) |
| |
| 更多精彩文章: |
| JSP数据库连接大全 |
| jsp中的数据库配置文件 |
| 配置jsp+mysql.txt |
| JSF+Spring+Hibernate的实例讲解 |
| server.xml 中各个域的说明 |
| 介绍一下 servlet.xml |
| |
| 最近评论: |
|
|
| 你曾悄悄的来过! |
| wow gold,wow gold,wow gold,ffxi gil max(2100) |
|
|
| 冰封的往事! |
| wow power leveling,wow gold,wow power leveling,wow gold
max(9497) |
|
|
| 冰封的往事! |
| wow power leveling,wow gold,WoW Gold,wow gold
max(1080) |
|
|
| 飞舞的传奇! |
| 传世私服,传世私服.传奇世界私服传奇世界私服,传世私服传世私服, 传奇世界私服传奇世界私服.传奇私服传奇私服. max(1040) |
|
|
| 回复:★jsp连接mysql数据库大全★ |
| Buy cheap RS gold,we are a professional, loyal and reliable runescape money and Runescape Money supplier online--24/7 non-stop service, cheap runescape gold and Rs Money with fast delivery.
24/7 buy runescape gold Shop -Fast,Reliable,Cheap Runescape Money|Runescape Gold|Buy Runescape Money - runescape money, runescape gold, runescape items, ..
RS gold site is selling RuneScape gold and RuneScape item,offering runescape gp RuneScape money, RuneScape gold and RuneScape 2 Gold are collected ...
|
|
|
| |
| 免责声明:该文章由网友发表,如果对您造成侵权,请联系站长。 |
|