-
1. Re: ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDataTable (not part of JDBC ?)
martinm1000 Jul 4, 2017 12:08 PM (in response to martinm1000)Ok, So I was able to fix the Class not found by adding to jboss-deployment-structure.xml :
<deployment>
<dependencies>
<module name="com.microsoft.sqlserver"/>
</dependencies>
</deployment>
but I now have a wrapper problem ?
org.jboss.jca.adapters.jdbc.jdk7.WrappedCallableStatementJDK7 cannot be cast to com.microsoft.sqlserver.jdbc.SQLServerCallableStatement
-
2. Re: ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDataTable (not part of JDBC ?)
martinm1000 Jul 4, 2017 5:16 PM (in response to martinm1000)Ok, I think I found the solution to the problem, which I'll explain below for others to find.
But I would like to know if there are better ways to achieve the same thing.
So I needed to have code under WildFly that use Microsoft SQL Server JDBC specific classes so I can use Table Valued Parameters:
SQLServerDataTable labor = make_tyPC_RateLaborTable();
try (SQLServerCallableStatement cs = (SQLServerCallableStatement)conn.prepareCall(FULL_MERGE_LABOR_RATES)) {
To have access to these classes, I needed to add the sqlserver module as a dependency (which I didn't have to do before since I used plain JDBC spec classes):
Added <module name="com.microsoft.sqlserver" slot="main"/> to jboss-deployment-structure.xml
Next, at run-time I got to see:
org.jboss.jca.adapters.jdbc.jdk7.WrappedCallableStatementJDK7 cannot be cast to com.microsoft.sqlserver.jdbc.SQLServerCallableStatement
After searching and trying a LOT of things, I found out that I needed to have the following code :
WrappedConnection wc = (WrappedConnection)connection;
Connection c = wc.getUnderlyingConnection();
and then i would have my instance of SQLServerCallableStatement through that SQL Connection.
To get the above code to compile, I found out (after hours of searching) that I needed a maven reference to:
<dependency>
<groupId>org.jboss.ironjacamar</groupId>
<artifactId>ironjacamar-jdbc</artifactId>
<version>1.3.4.Final</version>
<scope>provided</scope>
</dependency>
Then at run-time I still got problems, and I finally found out I needed to add some other stuff to my jboss-deployment-structure.xml, as follow:
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<dependencies>
<module name="org.jboss.ironjacamar.jdbcadapters" slot="main" export="true"/>
<module name="com.microsoft.sqlserver" slot="main"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
In the end, I also needed to have export to true to have it work.
So is there any other safer and less crazy way to achieve this ?