Compile a general information publishing program using JSP

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.