PDA

View Full Version : Microsoft SQL Server Supported?


fasslej
07-27-2010, 11:15 PM
Hello everyone. I'm looking to potentially do a Wordpress implementation using Quercus. However, we use Microsoft SQL Server for our database backend. Is Microsoft SQL Server supported by Quercus?

I haven't been able to find anyone who has done this. Has this been done yet? Is it possible?

If it is possible, but has yet to be done, what should I be looking at in order to complete this? I see that Microsoft has a "PHP Driver" for MSSQL Server, and obviously Microsoft has JDBC drivers on the Java side.

alex
10-11-2010, 06:28 PM
Resin certainly supports MS Sql JDBC driver, so it should be possible. You need to configure the datasource used for WordPress with Ms SQL jdbc driver: WEB-INF/resin-web.xml:

<database jndi-name="jdbc/blog">
<driver type="net.sourceforge.jtds.jdbc.Driver">
<url>jdbc:jtds:sqlserver://x.x.y.z.:1433/blog</url>
<user>user</user>
<password>pass</password>
</driver>
</database>

fifi
06-19-2013, 07:05 AM
Hello, sorry to refresh old thread but I have problem with what alex posted.
I try to connect to MSSQL 2008 R2 database called "test" on my localhost using Quercus/PHP

To the web.xml i added:
<database jndi-name="jdbc/sqlserver">
<driver type="net.sourceforge.jtds.jdbc.Driver">
<url>jdbc:jtds:sqlserver://127.0.0.1:1433/test</url>
<user>myuser</user>
<password>mypassword</password>
</driver>
</database>

In my .php file i have:
$db = new PDO("java:comp/env/jdbc/sqlserver");

And it gives me following error:
Fatal Error: 'java:comp/env/jdbc/sqlserver' is an unknown PDO JNDI data source.

I copied the jtds-1.3.1.jar to the lib folder. Do I need to do anything more to make this work?

fifi
06-25-2013, 12:33 PM
If anyone is interested I solved the problem:
Using Tomcat 7, i replaced the jtds driver with MS sqljdbc4 and added to the conf/context.xml following code:

<Context>
<Resource name="jdbc/sqlserver" auth="Container" type="javax.sql.DataSource" username="username" password="password" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost;databaseName=test"/>
Declaration of <database> in web.xml is now not required. It's maybe not the best solution but it seems to work fine with PDO.