jsp连接oracle(javabean)
package DBbean;
import java.sql.*;
public class ConnBean
{
private Connection con;
//初始化连接。
public ConnBean()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
con= DriverManager.getConnection(url,user,password);
}
catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
System.out.println("DRIVER NOT FOUND!");
con=null;
}
catch(SQLException e)
{
con=null;
}
}
//查询数据库
public ResultSet getContact(String id)
{
try
{
Statement stm=con.createStatement();
ResultSet result=stm.executeQuery("select * from student where id='"+id+"'");
return result;
}
catch(Exception e)
{
}
return null;
}
}
相关文档:
Oracle JOB 间隔时间详解
INTERVAL参数设置:
每天运行一次 'SYSDATE + 1'
每小时运行一次 &nbs ......
【训练6.1】 使用隐式游标的属性,判断对雇员工资的修改是否成功。
步骤1:输入和运行以下程序:
BEGIN
UPDATE emp SET sal=sal+100 WHERE empno=1234;
IF SQL%FOUND THEN
DBMS_OUTPUT.PUT_LINE('成功修改雇员工资!');
......
[root@GISDB ~]$ su - oracle
[oracle@GISDB ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Oct 13 11:03:03 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
To ......
用的数据库是mysql
【第一种方式,用JSP实现】
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
//**************************************
& ......