java ide 开发环境下第一次体验

我们所需要的软件
http://www.netbeans.org/kb/50/quickstart-gui.html
ide开发工具netbeans http;//www.netbeans.org
http://www.netbeans.info/downloads/download.php?type=5.0
mysql jdbc 驱动
http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.0.17-ga.zip/from/http://mirror.mysql-partners-jp.biz/
mysql就不用我说了,搜索一下就可以。
<%@page contentType="text/html"%>
<%@page pageEncoding="gb2312"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <title>我的第一个jsp程序</title>
    </head>
    <body>
    <form method="post" action="GetServlet.do">
        请输入您的名字: <input type="text" name="username">
  <input type="submit" value="查询" name="submit">
</form>       
<%!
String host="localhost";
String database="cendy";
String user="root";
String pass="";
%>
<%
java.sql.Connection sqlConn;
java.sql.Statement sqlStmt;
java.sql.ResultSet sqlRst;
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
sqlConn= java.sql.DriverManager.getConnection("jdbc:mysql://"+host+"/"+database,user,pass);
sqlStmt=sqlConn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
String sqlQuery="select count(*) from username";
sqlRst=sqlStmt.executeQuery(sqlQuery);
sqlRst.next();
int count=sqlRst.getInt(1);
sqlQuery="select * from username;";
sqlRst=sqlStmt.executeQuery(sqlQuery);
%>
一共<%=count%>条记录
<table border="0" width="35%" bordercolorlight="#CC99FF" cellpadding="1" bordercolordark="#FFFFFF" cellspacing="1">
  <tr align="center" bgcolor="#F4FCFF">
    <td width="18%">ID</td>
    <td width="49%">用户名</td>
    <td width="33%">密码</td>  
</tr>
<% while (sqlRst.next()) {%>
  <tr align="center" bgcolor="#F0F0F0">
    <td width="18%"><%=sqlRst.getString("id")%></td>
    <td width="49%"><%=sqlRst.getString("username")%></td>
    <td width="33%"><%=sqlRst.getString("passwd")%></td>
</tr>
<% } %>
</table>
</body>
<%
sqlRst.close();
sqlStmt.close ();
sqlConn.close();
%>    
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
        <!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    </c:if>
    --%>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值