<%
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException ae)
{
System.err.println("ae:" + ae.getMessage());
}
String sConnStr = "jdbc:odbc:fancydb";
Connection conn =null;
conn = DriverManager.getConnection(sConnStr,"sa","");
Statement stmt = conn.createStatement();
PreparedStatement prestmt=null;
ResultSet rs=null;
if(boolcanpost==true)
{
try
{
strSQL="insert into bbs (area,author,password,title,content,authorip) values (?,?,?,?,?,?)";
prestmt=conn.prepareStatement(strSQL);
prestmt.setBytes(1,area.getBytes("GBK"));
prestmt.setBytes(2,author.getBytes("GBK"));
prestmt.setBytes(3,password.getBytes("GBK"));
prestmt.setBytes(4,title.getBytes("GBK"));
prestmt.setBytes(5,content.getBytes("GBK"));
prestmt.setBytes(6,authorip.getBytes());
prestmt.executeUpdate();
}
catch (Exception de)
{
System.err.print("de.executeQuery: " + de.getMessage());
}
}
%>
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException ae)
{
System.err.println("ae:" + ae.getMessage());
}
String sConnStr = "jdbc:odbc:fancydb";
Connection conn =null;
conn = DriverManager.getConnection(sConnStr,"sa","");
Statement stmt = conn.createStatement();
PreparedStatement prestmt=null;
ResultSet rs=null;
if(boolcanpost==true)
{
try
{
strSQL="insert into bbs (area,author,password,title,content,authorip) values (?,?,?,?,?,?)";
prestmt=conn.prepareStatement(strSQL);
prestmt.setBytes(1,area.getBytes("GBK"));
prestmt.setBytes(2,author.getBytes("GBK"));
prestmt.setBytes(3,password.getBytes("GBK"));
prestmt.setBytes(4,title.getBytes("GBK"));
prestmt.setBytes(5,content.getBytes("GBK"));
prestmt.setBytes(6,authorip.getBytes());
prestmt.executeUpdate();
}
catch (Exception de)
{
System.err.print("de.executeQuery: " + de.getMessage());
}
}
%>
解决方案 »
- 关于struts2按条件 模糊查询!!!!!!!!!!!!
- struts 1.3如何实现跨目录的跳转,在线等......急?
- while((c=dis.readChar())!='\0')的疑问?在线等
- 请问怎么把javabean连接MYSql的语句拆开写呀?
- 贡献出全部分数求jstl教程一份
- 请教hibernate熟手一个数据库连接的问题,在线等,急!!!全部分都上啦
- 急找一个利用JavaScript对页面上生成的表格进行排序的js源代码。
- Jsp里如何取当前时间和月份
- jsp和servlet之间的对象传递问题
- struts2 多个jsp页面传值到action后返回当前对应页面
- 如何用JSP 编写电子邮件的附件发送???
- applet与servlet通讯以及对象序列化问题?感谢各位的关注!!!
我的tomcat中提示我的register.jsp has no values是怎么回事呢??????
Statement sqlStmt; //语句对象
ResultSet sqlRst; //结果集对象
Driver driver; //驱动对象
//jdbc驱动程序的路径
String dbDriver="oracle.jdbc.driver.OracleDriver";
//jdbc url的标准语法有三部分组成,jdbc:<子协议>:<子名称>
String dbServer="jdbc:oracle:thin:@192.168.3.244:1521:IT1";
String dbLogin="suntory";
String dbPassword="suntory";
String sql3="select count(*) rowcount from UserMst";
//登记JDBC驱动程序
// driver=(Driver)Class.forName(dbDriver).newInstance();
Class.forName(dbDriver).newInstance();
//连接数据库
// sqlConn = driver.connect(sConnect, new Properties());
sqlConn = java.sql.DriverManager.getConnection(dbServer,dbLogin,dbPassword);
//创建语句对象
sqlStmt=sqlConn.createStatement();
//执行SQL语句
sqlRst=sqlStmt.executeQuery(sql3);