最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
JSP记事本程序
时间:2022-07-02 17:51:25 编辑:袖梨 来源:一聚教程网
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 align="center" border=1>
<tr>
<td >
<div align="right">Name:</div>
</td>
<td >
<input type="text" name="name">
</td>
</tr>
<tr>
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 align="center" border=1>
<tr>
<td >
<div align="right">Name:</div>
</td>
<td >
<input type="text" name="name">
</td>
</tr>
<tr>
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22