ORA-00942: table or view does not exist

i've solved this problem just now and i'll write my way as follows:

1st- environment discription:

tools: Eclipse3.2,myeclipse5.0,oracle 9i,Tomcat5 

tech: Struts

2nd- relative codes:

 <data-sources>
   <data-source  key="oracleDB1">
    <set-property property="driverClass"
    value="oracle.jdbc.driver.OracleDriver"/>
    <set-property property="url"
    value="jdbc:oracle:thin:@192.168.20.60:1521:ora9i"/>
    <set-property property="maxCount" value="10"/>
    <set-property property="minCount" value="1"/>
    <set-property property="user" value="center"/>
    <set-property property="password" value="center"/>
    <set-property property="autoCommit" value="true"/>
   </data-source>
  </data-sources>

  DataSource dataSource=(DataSource)context.getAttribute("oracleDB1");
  try{
   Connection conn = dataSource.getConnection();
   Statement stmt = conn.createStatement();
   String sql="insert into users values('"+name+"','"+psw+"')";
   int result = 0;
   result=stmt.executeUpdate(sql);   
   if(result==1){
    return(mapping.findForward("registed"));
   }
  }catch(SQLException e){
   e.printStackTrace();
  }
  return(mapping.findForward("failed"));

3rd- error message:

ORA-00942: table or view does not exist

4th- analyse:

i've created table 'user' with pl-sql developer and could query from oracle, but the programme made a mistake on the line'   result=stmt.executeUpdate(sql);  ',and then i execute the query sentence with sql-plus, it shows the same error. therefore i knew where the problem took place:

my order of implement:

1.create table 'user'  with the username 'sysman' and the password'oem_temp';

2.create a new ID'center' and then grant previlege of dba;

3.use the username 'center' to connect database in code;

the correct order should be first to create new ID,and then create table under it . so that could we use it in code.

5th- measure:

1.drop the previous table 'user';

2.create table 'user'  with the username 'center' and the password'center';

3.use the username 'center' to connect database in code;

the result will be right

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值