欢迎光临
我们一直在努力

用JSP编写通用信息发布程序-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

信息发布界面

提供发布信息的交互界面,调用 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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用JSP编写通用信息发布程序-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章