on 03-27-2007 5:24 PM
Hy,
I want to realize database access with sqlj.
I created an EJB project with a stateless session bean with some business methodes I didn't implemented yet. I wanted to create a Connection Context file and a file for data access. What I did is: creating two sqlj-files in a package named sqlj which appeard in the folder gen_sqlj of the EJB-project. After I changed the connection context file, a .java file was created.
In the property window of the project I added this folder to the java build path in tab sources. Now the package sqlj with the two sqlj-files is in folder ejbModule. I wonder where the .java file has gone.
What do I have to write in the Connection Context .sqlj Class ?
If I write:
[code]#sql public context Ctx with (dataSource = "java:comp/env/TEACHER_MANAGEMENT");[/code]
I have to define this dataSource alias in the EAR project. Is this correct?
If I have no dataSource alias specified, do you expect the following code to work?
[code]#sql public context Ctx with (dataSource = "${com.sap.datasource.default}");[/code]
The file for data access looks like this:[code]
public long createSubject(String name, String description) throws SQLException{
Ctx ctx = new Ctx();
try{
long id=IdGenerator.getNewId();
#sql [ctx] {insert into PERSIST_SUBJECT (ID, NAME, DESCRIPTION)
values (:id, :name, :description)};
return id;
}
finally{
if(ctx!=null){
ctx.close();
}
}
return 0;
}
[/code]
I get the error:
SQLJ: The catalog reader is either not specified or inaccessible.
SQLJ: Unable to perform semantic analysis on connection sml/file/. Error returned by database is: "The path to the catalog reader is empty."
Can anyone help me to solve this problem or to understand what I did wrong or forgot?
Regards,
Carina
Hi Carina,
Have you already checked the <a href="http://help.sap.com/saphelp_nw04/helpdata/en/af/9373757f30e148b7548b5d8c3d298a/frameset.htm">Open SQL/SQLJ</a> section in the Development Manual?
Regarding your question about the dataSource - you should include a resource reference for the relevant DataSource in the ejb-jar.xml deployment descriptor, as described in the <a href="http://help.sap.com/saphelp_nw04/helpdata/en/70/a19cc472e72c4481172909938578fc/frameset.htm">Database Connection Context</a> section of the manual. For other questions, please also check the manual.
Hope it helps!
-Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.