js| Program
Information Publishing Interface
Provides an interactive interface for publishing information and invokes the RECORDMESSAGE.JSP program.
saymessage.jsp
<HTML> <HEAD> <TITLE> Information Release </TITLE>
<meta content = "text/html; charset=gb2312 "HTTP-EQUIV = content-type>
<link href = "Css_01.css" rel = stylesheet>
<meta content = "MSHTML 5.00.3103.1000" name =generator> </HEAD>
<BODY>
<% @ Page contenttype= "text/html; charset=gb2312 "% >
<% @ Page language= "java" import= "java. sql. *"% >
<jsp:usebean id = "rencommend" scope= "page" class= "ymbean.opdb"/>
<form Action =recordmessage.jsp Method =post name=sign>
<input Name=dtkey Type=hidden value=ta_routes>
<table bgcolor= #d5e8fd border=0 cellspacing=1 width= "97%" >
<tbody>
<tr> <td nowrap width= "45%" height= "185" >
<div align=left>
<table bgcolor= #d5e8fd border=0 cellspacing=1 width= "100%" >
<tbody>
<tr> <td nowrap width= "100%" > Line name:
<input maxlength=100 name = Routename size=36>
</td>
</tr>
<TR><TD nowrap width= "100%" > Display serial Number:
<input maxlength=3 Name=routeno size=36>
</td></tr>
<tr>
<TD width= "100%" > Tour content. When the text is over one line, please enter the key line </td>
</tr>
<TR><TD width= "100%" height= "162" >
<textarea cols=55 name =C04 rows=9>
</TEXTAREA>
</TD>
</TR></TBODY></TABLE></DIV></TD></TR>
<TR><TD Align=middle colspan=2 nowrap>
<input name=cmdcommit type=submit value= "Submit" >
</td></tr></tbody></table>
</form></center>
<div></div></body>
Connecting to a database
Connect the Oracle database by invoking the Java Bean.
Opdb.java
Package Ymbean; Java Packages
Import java.sql.*;
public class Opdb {
Public opdb () {}
Public ResultSet executequery (String sql)
{
ResultSet rs = null;
Statement lstmt = null;
try {lstmt = Connectdb ();
rs = lstmt.executequery (SQL);
System.out.println ("executequery:" + sql);
The catch (SQLException ex) {return (null);}
Return RS;
}
public string executeupdate (String sql)
{
ResultSet rs = null;
Statement lstmt = null;
try {
lstmt = Connectdb ();
Lstmt.executeupdate (SQL);
System.out.println ("executeupdate:" + sql);
Lstmt.executeupdate ("commit");
}catch (SQLException ex) {}
Return ("executeupdate OK");
}
Connecting to a database
Public Statement Connectdb ()
{Statement lstmt=null;
Connection Conn=null;
Final String connect_string= "Jdbc:oracle:thin:scott/tiger@192.168.0.1:1521:test";
Final String driver_string= "Oracle.jdbc.driver.
Oracledriver ";
Connection Lconn;
try {class.forname (DRIVERSTR);
Lconn=drivermanager.getconnection (CONNECTSTR);
Lstmt=lconn.createstatement ();
catch (Exception e) {return (null);}
return lstmt;
}
}//end Opdb.java