<%@ 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();
%>