Skip to Content
0
Former Member
Mar 27, 2007 at 04:24 PM

SQLJ connection problem

18 Views

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