[jboss-user] [JCA/JBoss] - Configuration of data source
abdujaparov
do-not-reply at jboss.com
Tue Apr 7 16:57:17 EDT 2009
Hi,
I followed this guide http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Installation_And_Getting_Started_Guide/5/html/Using_other_Databases.html#creating_a_jdbc_client to configure datasource in jboss5 but I receive an errore when I try to execute this jsp page:
| <%@page contentType="text/html"
| import="java.util.*,javax.naming.*,javax.sql.DataSource,java.sql.*"
| %>
| <%
|
| DataSource ds = null;
| Connection con = null;
| PreparedStatement pr = null;
| InitialContext ic;
| try {
| ic = new InitialContext();
| ds = (DataSource)ic.lookup( "java:/DefaultDS" );
| con = ds.getConnection();
| pr = con.prepareStatement("select cognome, nome, squadraA from giocatore");
| ResultSet rs = pr.executeQuery();
| while (rs.next()) {
| out.println("<br> " +rs.getString("cognome") + " | " + rs.getString("nome") + " | " +rs.getString("squadraA"));
| }
| rs.close();
| pr.close();
| }catch(Exception e){
| out.println("Exception thrown " +e);
| }finally{
| if(con != null){
| con.close();
| }
| } %>
|
The error tells me that the table 'giocatore' does not exist but the query is correct, if I try it on a the db I receive the correct response.
So I followd this other guide: http://www.jboss.org/community/wiki/SetUpMysqlAsDefaultDS
but I have sono problem:
1) after I deleted $JBOSS_HOME/server/default/deploy/hsqldb-ds.xml and inserted $JBOSS_HOME/docs/examples/jca/mysql-ds.xml in $JBOSS_HOME/server/default/deploy the guide say I have to modify the file $JBOSS_HOME/server/default/conf/standardjaws.xml but in my directory this file does not exist.
2) I changer in this way:
java:/DefaultDS <datasource-mapping>mySQL</datasource-mapping> <fk-constraint>true</fk-constraint>
the text in standardjbosscmp-jdbc.xml
3) I copied these lines:
| <application-policy name = "MySqlDbRealm"> <authentication> <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required"> <module-option name = "principal">angelo</module-option> <module-option name = "userName">angelo</module-option> <module-option name ="password">palermo</module-option> <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option> </login-module> </authentication> </application-policy>
|
where username and passowrd belongs to the db.
4)The point 7 of the guide says: anonymous wrote : Replace file $JBOSS_HOME/server/default/deploy/jms/hsql-jdbc2-service.xml by file $JBOSS_HOME/docs/examples/jms/mysql-jdbc2-service.xml
but the path does not exist in my jboss5 so the point 8 and 9 of the guide are not completed.
When I try to execute the jsp I receive this error:
| Exception thrown javax.naming.NameNotFoundException: DefaultDS not bound
|
So how can I configure datasource?
Thanks, bye bye.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4224168#4224168
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4224168
More information about the jboss-user
mailing list