servlet版sql在线工具

servlet版sql在线工具,以下是执行sql的核心部分。
以前用java写过一个同样的工具。现在想起当时对编程还是缺乏经验,对于出错处理,文本识别方面考虑不周,写的也不够规范。附上java版sql 工具。以供自己警记。

public void executeSql(String sql, HttpServletResponse response)
   throws ServletException, IOException {

   PrintWriter out = response.getWriter();
   try {
     //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection con = DriverManager.getConnection("jdbc:odbc:JavaWeb");
     System.out.println("got connection");
继续阅读“servlet版sql在线工具”

Should I Keep the Connection Open?

写数据库程序的时候每次进行数据库相关操作结束后都马上加句connection.close;关闭与数据库的连接。从来没有人说明这是个惯例,还是必须,所有的范例都是这么写,却都没有解释,保持数据库连接不是更好么?现代数据库不是都支持并行操作的?为什么还要这样。今天我有了自己的看法。

All the examples given up to this point in this chapter have closed the Connection object after the servlet services the request. However, you might ask the following question: If the servlet is called more than once and it opens a Connection object with the same arguments (url, user, and password) each time, wouldn’t it better to leave the Connection object open for future use; that is, for when the servlet is called again?
继续阅读“Should I Keep the Connection Open?”

CheckCookieServlet

一个非常简单实用的检查用户浏览器是否支持cookie的servlet,不支持则给出输出提示。
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class CheckCookieServlet extends HttpServlet {
 /**Process the HTTP Get request*/
 public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   if (request.getParameter("flag")==null) {
     // the first request
继续阅读“CheckCookieServlet”

iwind.cn

      今天注册个.cn的域名.而且一注就是3年,我没疯噢.主要是够便宜.才19块一年.刚开始还怀疑是不是真的,交了一年钱,想被骗也就算了.没想到是真的.马上续费2年.要不是还要留点钱给biyao.我全拿去续费了.3年才五十多.想我那个.com的.那么老贵.字母还老多,都不想在用了..都够我注册5年.cn的了.亏死了 ..今天就光注册域名,找空间,搬博客忙和了好久.不过很好.总算是搞定了.放心多了.以后就用自己域名的信箱啦..

新空间

   嗯.把数据库迁移过来了.感觉比放在db4free放心多了.先在好了.要丢就全丟了..以前还分两地.
db4free还是留着拿来做实践好了.毕竟那边是最新的mysql 5.1  
   把ns服务器改了回来,给pandela的服务器添了调A记录,主要是pandela不让设mx记录实在无法忍受,目前A记录已经生效,但是mx记录还没改过来,ns服务器全球刷新实在太慢了.忍不了了.
 也许我总是个喜新厌旧的人,我对很多东西感兴趣然后又很容易失去兴趣.学的东西.玩的东西.都是如此.这个都开始让我有些害怕.担心自己都没有好的结果,时间好快.都8月10号了.最近进度太慢,明天看来得加把劲了,小外甥有点烦,开始有些厌倦了..