日期:2014-05-16 浏览次数:20674 次
Oracle:9i 系统:Windows XP
CREATE TABLESPACE myweb LOGGING DATAFILE ' D:\Oracle\oradata\testdata\myweb.DBF' SIZE 32M AUTOEXTEND ON NEXT 32M MAXSIZE 2048M EXTENT MANAGEMENT LOCAL;
CREATE USER myuser IDENTIFIED BY 123456
DEFAULT TABLESPACE myweb
GRANT CREATE SESSION, CREATE ANY TABLE, CREATE ANY VIEW ,CREATE ANY INDEX, CREATE ANY PROCEDURE,ALTER ANY TABLE, ALTER ANY PROCEDURE, DROP ANY TABLE, DROP ANY VIEW, DROP ANY INDEX, DROP ANY PROCEDURE, SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE, DELETE ANY TABLE TO myuser; grant dba to myuser;
ORA-00942: 表或视图不存在
CREATE TABLE testuser(id int,name varchar(50),password varchar(50), chiname varchar(50),info varchar(100)) TABLESPACE myweb; insert into testuser values(1,'hehe1','123456','hehe1','i am hehe1'); insert into testuser values(2,'hehe2','123456','hehe2','i am hehe2'); insert into testuser values(3,'hehe3','123456','hehe3','i am hehe3'); insert into testuser values(4,'hehe4','123456','hehe4','i am hehe4');
public class OraDao { protected static String driver = "oracle.jdbc.driver.OracleDriver"; protected static String url = "jdbc:oracle:thin:@111.111.11.111:1521:testdata"; protected static String dbUser = "myuser"; protected static String dbPwd = "123456"; private Connection conn =null; public Connection getDaoconn(){ if(conn==null){ try { Class.forName(driver); conn = DriverManager.getConnection(url, dbUser, dbPwd); } catch (Exception e) { e.printStackTrace(); } } return conn; } public OraDao() { } /** * @执行数据库查询操作 */ public ResultSet executeQuery(OraDao dao,String sql) { ResultSet result = null; try { result = dao.getDaoconn().createStatement().executeQuery(sql); } catch (SQLException e) { e.printStackTrace(); return null; } //d.close_result(result); //d.close_Dao(d); return result; } /** * @执行数据库更新操作 */ public int executeUpdate(OraDao dao,String sql) { int info = 0; try { info = dao.getDaoconn().createStatement().executeUpdate(sql); } catch (SQLException e) { System.out.println(e.getMessage()); return -1; } //dao.close_Dao(dao); return info; } // 关闭数据库连接 public void close_conn(Connection conn) { try { if(conn!=null){ conn.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { //conn = null; } } // 关闭数据库连接 public void close_result(ResultSet result) { try { if(result!=null){ result.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { //conn = null; } } public void close_Dao(OraDao dao){ if(dao.getDaoconn()!=null){ dao.close_conn(dao.getDaoco