Using JSP to write General Information release Program _JSP programming

Source: Internet
Author: User
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>
&LT;TR&GT;&LT;TD nowrap width= "100%" > Display serial Number:
<input maxlength=3 Name=routeno size=36>
</td></tr>
<tr>
&LT;TD width= "100%" > Tour content. When the text is over one line, please enter the key line </td>
</tr>
&LT;TR&GT;&LT;TD width= "100%" height= "162" >
<textarea cols=55 name =C04 rows=9>
</TEXTAREA>
</TD>
</TR></TBODY></TABLE></DIV></TD></TR>
&LT;TR&GT;&LT;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
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.