Bonjour,
est ce que quelqu'un sait comment faire pour creer une datasource oracle dans struts?
Voici ce que j'ai mis dans mon struts-config.xml
et voici ce que j'ai mis dans mon action:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14<data-sources> <data-source type="org.apache.commons.dbcp.BasicDataSource" key = "test"> <set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <set-property property="URL" value="jdbc:oracle:thin:@pizia:1521:MYSCHEMA" /> <set-property property="username" value="ALPHA" /> <set-property property="password" value="BETA" /> <set-property property="maxActive" value="10" /> <set-property property="maxWait" value="5000" /> <set-property property="defaultAutoCommit" value="false" /> <set-property property="defaultReadOnly" value="false" /> <set-property property="validationQuery" value="SELECT * FROM MY_TABLE" /> </data-source> </data-sources>
Est ce que quelqu'un pourrait me dire pourquoi ca marche pas?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 try { dataSource = (DataSource)servlet.getServletContext().getAttribute("test"); myConnection = dataSource.getConnection(); stmt = myConnection.prepareStatement("select title from MY_TABLE"); rst=stmt.executeQuery(); System.out.println("******************************************"); System.out.println("********Out Put from TestDataSource ******"); while(rst.next()) { System.out.println("Title is " + rst.getString("TITLE")); System.out.println("******************************************"); } } catch (SQLException sqle) { sqle.printStackTrace(); getServlet().log("Connection.process", sqle); } catch (Exception e) { e.printStackTrace(); } //} finally { try { rst.close(); stmt.close(); myConnection.close(); } catch (SQLException e) { getServlet().log("Connection.close", e); } } /***end DataSource***/ return mapping.findForward(PRINT);
Merci




Répondre avec citation





Partager