cancel
Showing results for 
Search instead for 
Did you mean: 

EJB - MS SQL

Former Member
0 Kudos

Hi there,

Can someone tell me:

-how to create a datasource for MS SQL server? Do you also have to install a SQL server driver and such?

-how to connect to MS SQL & execute queries from EJB? Are there specific jars or something that have to be added to the EJB?

If possible a step-by-step?

Thanks

Kind regards

Accepted Solutions (1)

Accepted Solutions (1)

ankur_garg5
Active Contributor
0 Kudos

Hi Allan,

Try going through my article once:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/b00917dc-ead4...

If I am not wrong, your problem should get solved by this document. Leave that portion of the document where I explain how to create a web service from the EJB.

Bye

Ankur

Former Member
0 Kudos

Hi Ankur,

Coincidentally, I stumbled upon your article this morning.

It was useful as my datasource didn't work before due to one of the following reasons:

-Open SQL: tables have to be rigistered via JDDI before using the db (if you know how, that would be helpful), but apart from that, there was another error:

JDBC driver not supported for MS_SQL_SERVER database.

-Native SQL: didn't work either; same exception.

-Vendor SQL: this works.

Only thing I'm afraid of is that when the DB crashes, you won't have an automatic reconnection via vendor SQL.

Did you take this into account or...? If yes, how?

Thanks a lot!

ankur_garg5
Active Contributor
0 Kudos

Hi Allan,

I am afraid we did not take care of DB crashes at that time. I did this as part of a POC long time back (1 year). So wouldn't be able to provide much input on it.

Bye

Ankur

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Allan,

try to fetch data via EJB QL from database in this u can create tables in java dictionay. n entity beans can b used for data store to database. u can access data base via creation of web service for session bean which will contain ur business logic.

Go through this : [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ca4a9c90-0201-0010-c389-8738cd51a88e]

u can test it via making webservice of session bean directly..

or u can use web dynpro interface wid EJB..

Regards,

Khushboo

Former Member
0 Kudos

Hi,

Please go through this blog

/people/anilkumar.vippagunta2/blog/2007/02/20/reading-and-writing-images-from-sqlserver-in-webdynpro

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapparaj,

Thanks a lot! However I have a question.

Isn't it necessary to also make use of a javabeans model?

If you have a document on how you did this, that would be great!

I need to get data from MS SQL via EJB.

That EJB has to be used in webdynpro and somehow the fetched data has to be shown in a table. I know this can be done via context, but isn't there a need for a model based on EJB?

I just don't understand what I can do in EJB (for the model) since I only need to fetch data from SQL and show it on the screen...

Kind regards

Former Member
0 Kudos

Hi,

You have two options to acheive this

1) One is what you have mentioned using Bean model to do this you have to create DTO out of your EJB and use this for model import

2) Create webservice out of your EJB and use adaptive webservice .

https://sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/600cb8d1-a8be-2910-a0b1-f13d32d42690

Regards

Ayyapparaj

Former Member
0 Kudos

Thanks Ayyapparaj,

Do you perhaps have a how-to document or example or something regarding creating EJB models from DTO?

Kind regards,

Allan

Former Member
0 Kudos

Hi,

Following blog may shed some light

/people/valery.silaev/blog/2005/06/29/apojo--almostplain-old-java-objects-as-model

Regards

Ayyapparaj