cancel
Showing results for 
Search instead for 
Did you mean: 

SQLJ connection problem

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Vlado
Advisor
Advisor
0 Kudos

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