Information Publishing Interface
Provides an interactive interface for publishing information and calls the recordMessage. jsp program.
SayMessage. jsp
<HTML> <HEAD> <TITLE> information publishing </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 Sequence Number:
<Input maxlength = 3 name = routeno size = 36>
</Td> </tr>
<Tr>
<Td width = "100%"> contents of the tour. When the text is too long, please press Enter to wrap the 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 = submit commit type = submit value = "submit">
</Td> </tr> </tbody> </table>
</Form> </center>
<Div> </body>
Connect to database
Connect to the Oracle database by calling Java Bean.
OpDb. java
Package ymbean; // java package
Import java. SQL .*;
Public class opDb {
Public opDb (){}
Public ResultSet executeQuery (String SQL)
{
ResultSet rs = null;
Statement lstmt = null;
Try {lstmt = connectdb ();
Rs = lstmt.exe cuteQuery (SQL );
System. out. println ("executeQuery:" + SQL );
} Catch (SQLException ex) {return (null );}
Return rs;
}
Public String executeUpdate (String SQL)
{
ResultSet rs = null;
Statement lstmt = null;
Try {
Lstmt = connectdb ();
Lstmt.exe cuteUpdate (SQL );
System. out. println ("executeUpdate:" + SQL );
Lstmt.exe cuteUpdate ("commit ");
} Catch (SQLException ex ){}
Return ("executeUpdate OK ");
}
// Connect to the 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