分类分类
关注+2009-11-10作者:
注意:所有小写有下划线的地方均要自己改,如user_name,table_value1.....
<%@ page contentType="text/html; charset=utf-8" language="java"
import="java.sql.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%
String server="localhost";
String dbname="user_database"; //database名字
String user="user_name"; //用户名
String pass="user_password"; //密码
String url ="jdbc:mysql://"+server+"/"+dbname+"?user="+user+"&password="+pass;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sql="select * from user_table"; //table名字
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
out.print("table_value1");
out.print(rs.getString("table_value1")+" table_value2");
out.println(rs.getString("table_value2")+"<br>");
}
rs.close();
stmt.close();
conn.close();
%>
<%
out.print("<br>");
out.print("数据库操作成功,恭喜你");
rs.close();
%>
-
相关文章
更多+相同厂商
热门推荐
点击查看更多
点击查看更多
点击查看更多
说两句网友评论