I have created a simple JSF application, now must to connect to SQL Server and perform CRUD operations on those tables from database.
I was a .NET programmer and i don’t know how to connect to SQL Server from JSF. I have read something about JNDI, but not understood well. My questions are:
- where should JNDI be defined: on Tomcat or my application?
- where to define the connection string?
- which driver/jar should be used?
Can you recommend any code samples, links to tutorials how to perform crud operations, or any other guidance?
In the JNDI container. That’s thus Tomcat.
In the JNDI container. In case of Tomcat, that’ll go in the
context.xml. You can either modify Tomcat’s owncontext.xmlor supply your own inMETA-INFfolder of your webapp. More details can be found in the Tomcat JNDI resources HOW-TO.The one which can communicate with the DB in question. In case of Microsoft SQL Server, that’s under each the DB-vendor provided JDBC driver or the performancetechnically better jTDS driver.
Here are some useful tutorials which might help you step by step further: