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