程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> JSP記事本程序

JSP記事本程序

編輯:關於JSP

package guestbook;
import java.sql.*;
public class guestbook{
  String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
  String sConnStr = "jdbc:odbc:guestbook";
  Connection conn = null;
  ResultSet rs = null;
 
  public guestbook() {
try {
      Class.forName(sDBDriver);  
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("guestbook(): " + e.getMessage());
}
  }
  public void executeInsert(String sql) {
    try {
conn = DriverManager.getConnection(sConnStr);    
     Statement stmt = conn.createStatement();
     stmt.executeUpdate(sql);
    }
    catch(SQLException ex) {   
System.err.println("guestbook.executeUpdate: " + ex.getMessage());
    }
  }
  public ResultSet executeQuery(String sql) {
  rs = null;
    try {
conn = DriverManager.getConnection(sConnStr);    
     Statement stmt = conn.createStatement();
     rs = stmt.executeQuery(sql);
    }
    catch(SQLException ex) {   
System.err.println("guestbook.executeQuery: " + ex.getMessage());
    }
    return rs;
  }
}
<html>
<head>
<title>My First Jsp GuestBook</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#CCCCFF" vlink="#000000" alink="#666666">
<div align="center">
 <p><font size="7"><b><font size="+6">Jsp GuestBook</font></b></font></p>
 <form method="post" action="index.jsp">
  <table width="75%" align="center" border=1>
   <tr>
    <td width="30%">
     <div align="right">Name:</div>
    </td>
    <td width="70%">
     <input type="text" name="name">
    </td>
   </tr>
   <tr>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved