Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problem while executing the stored procedure
Problem while executing the stored procedure [message #387429] Wed, 29 April 2009 06:13 Go to next message
kondal is currently offline kondalFriend
Messages: 2
Registered: July 2009
Junior Member
Hi,
I have a simple procedure in SQLServer database.While I am executing
the procedure using EclipseLink JPA I am getting some errors.


Project project = new Project();
DatabaseLogin login = new DatabaseLogin();
login.setUserName(DATABASE_USERNAME);
login.setPassword(DATABASE_PASSWORD);
login.setConnectionString(DATABASE_URL);
login.setDriverClassName(DATABASE_DRIVER);
login.setDatabaseName("testdemo22");
project.setDatasourceLogin(login);
Session s = project.createDatabaseSession();
s.setLogLevel(SessionLog.FINE);
((DatabaseSession)s).login();

StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("insert_user");//procedure name
DataModifyQuery query = new DataModifyQuery();
query.setCall(call);
s.executeQuery(query);

When I run this code I am gettting the folllowing errors.

Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException:
Incorrect syntax near the keyword 'PROCEDURE'.
Error Code: 156
Call: EXECUTE PROCEDURE insert_user()
Query: DataModifyQuery()
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0 (Build
1.0 - 20080707)): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException:
Incorrect syntax near the keyword 'PROCEDURE'.
Error Code: 156
Call: EXECUTE PROCEDURE insert_user()
Query: DataModifyQuery()
at
org.eclipse.persistence.exceptions.DatabaseException.sqlExce ption(DatabaseException.java:313)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseAcce ssor.executeDirectNoSelect(DatabaseAccessor.java:757)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseAcce ssor.executeNoSelect(DatabaseAccessor.java:823)



Any Ideas please?

Regards
kondal
Re: Problem while executing the stored procedure [message #387434 is a reply to message #387429] Wed, 29 April 2009 13:01 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Make sure you set your DatabasePlatform in your login to SQL Server.

i.e.
login.useSQLServer();

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Problem while executing the stored procedure [message #387439 is a reply to message #387434] Wed, 29 April 2009 14:23 Go to previous messageGo to next message
kondal is currently offline kondalFriend
Messages: 2
Registered: July 2009
Junior Member
Thanks.It is working.Is there any generic method to login to any database.


Regards
kondal
Re: Problem while executing the stored procedure [message #387444 is a reply to message #387439] Thu, 30 April 2009 13:09 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Since you are setting other database/driver specific information on the
login, it is probably not a big deal to also set the platform.

In JPA if you do not set the platform it is auto-detected by default.
Using the native API you can do this by calling loginAndDetectDatasource()
on DatabaseSessionImpl instead of login().

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Previous Topic:EclipseLink+Spring+ComboPooledDataSource+MySQL ORM not persisting
Next Topic:Support for views in eclipse link
Goto Forum:
  


Current Time: Thu Apr 25 13:11:20 GMT 2024

Powered by FUDForum. Page generated in 0.03627 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top