JNDI – configuration database connection to SQL Server 2012 in GlassFish for JSTL

First You must downloading driver of SQL Server ( sqljdbc4.jar ). Copy it into lib directory in GlassFish instalation place. Mine it is:

C:\Program Files\glassfish-4.0\glassfish\lib

Next run GlassFish server. I run it in Netbeans right clicking the GlassFish node in Servers and choose Run.

If server is running, open browser with address:

http://localhost:4848 

The Administrative Console appear.

Click the JDBC item on the left section in Resources node.
You see two links.

Click the JDBC Connection Pools link.
It will be display list of Connection Pools. Click the New button.

You see New JDBC Connection Pool section.

Write your own pool name. I mine name as SQLServer2012. from list of Resource Type select as javax.sql.DataSource.
From list of Database Driver Vendor choose MicrosoftSqlServer. Click the Next button.

In second step You see these data:

You must filling field: URL, User, Password, DatabaseName, ServerName.

My URL is jdbc:sqlserver://DORA-KOMPUTER\SQLEXPRESS:1433;

Click the Finish button.

Go to the Resources section and click the JDBC Resources.

You see list of JNDI Names.

Click the New button. It displays configuration section.

In JNDI Name field write jdbc/sql2012 or your own name. From Pool Name select your defined pool: SQLServer2012.
In Description field write for example: SQL Server 2012 or leave empty. Click the OK button.

On the list you see new JDBC Resource.

If you click in JDBC Resources node jdbc/_default, you may select Pool Name as SQLServer2012 and click Save button.

Test connection pool. Choose from JDBC Connection Pools item SQLServer2012 and click Ping button.

If it’s all right you see information about success:

Restart GlassFish server.