CSDN博客

img panzi667

JSP朝ORACLE的插入代码

发表于2004/10/12 17:03:00  803人阅读

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html><head><title>JSP朝ORACLE的插入代码</title>
</head><body>
<%
String teststr="小白";
%>
<br>
output:<br>
------------------
<%=teststr%>
------------------<br>
Font Code Change and IntoOracle:<BR>
----------------------<BR>
<%
//字符转换
String IntoDB = new String(teststr.getBytes(),"iso8859-1");

Class.forName("oracle.jdbc.driver.OracleDriver");
String s_db_connection_string="jdbc:oracle:thin:@192.168.0.2:1521:server";
Connection con = DriverManager.getConnection(s_db_connection_string,"gu","jian");
String sql="INSERT INTO test(a) VALUES('"+IntoDB+"')";
PreparedStatement pstmt=con.prepareStatement(sql);
pstmt.executeUpdate();
pstmt.close();
con.close();
%>

阅读全文
0 0

相关文章推荐

img
取 消
img