用JSP編寫通用資訊發布程式

來源:互聯網
上載者:User

資訊發布介面

提供發布資訊的互動介面,調用 recordMessage.jsp程式。

sayMessage.jsp
<HTML> <HEAD> <TITLE> 資訊發布</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%" >線路名稱:
<input maxlength=100 name = routename size=36>
</td>
</tr>
<tr><td nowrap width="100%">顯示序號:
<input maxlength=3 name=routeno size=36>
</td></tr>
<tr>
<td width="100%" >遊覽內容。文字超一行時 ,請您敲 Enter鍵換行</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="提交">
</td></tr></tbody></table>
</form></center>
<div></div></body></html>

串連資料庫

通過調用 Java Bean串連 Oracle資料庫。

opDb.java

package ymbean; // java包

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);

} 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” );

}

//串連資料庫

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.