Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Programming / Connectivity / July 2009

Tip: Looking for answers? Try searching our database.

Checking state of sendStringParamaterAsUnicode in External DataSou

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wes Clark - 22 May 2009 16:49 GMT
Our ISV application supports using SQL Server with either single byte varchar
columns, or all nvarchar columns.  We support an internal connection pool
(DBCP), but also using WebSphere or WebLogic external connection pools.  When
our application starts, I want to check that the setting of
SendStringParameterAsUnicode is appropriate for the type of database being
used; i.e., "false" for single byte databases, and "true" for multibyte
databases.  

The only method I can see that would tell me this is on the
SQLServerDataSource interface.  I have yet to find a way to get a reference
to an object with this interface.  When I use JNDI to look up and get a
reference to the datasource from a WebSphere datasource, is a
WSJdbcDataSource object.  When I try to "unwrap" this object, I get:  
java.sql.SQLException: DSRA9122E:
com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@d7257754 does not wrap any objects
of type com.microsoft.sqlserver.jdbc.SQLServerDataSource.  I've also tried to
cast it, but it is not an "instanceof" the Microsoft interface.  The
MicrosoftConnection object has a method for this property, but it has package
visibility (it is not public).

In short, my question is how to check the state of
SendStringParametersAsUnicode in a third-party datasource constructed with
the Microsoft 2.0 JDBC driver?
Wes Clark - 22 May 2009 17:04 GMT
Cross posted in SQL Server Data Access forum at
http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/7a017a82-03d2
-483f-a1da-fdc0402acae0
.
Wes Clark - 30 May 2009 06:17 GMT
I got it to work:  Either using the officially WAS 7.0.0.3 supported MS 1.2
JDBC driver, or the not-yet-supported 2.0 MS JDBC driver, this approach
works.  The Java code I am using is

     final Class<?> wsCallHelper =
Class.forName("com.ibm.websphere.rsadapter.WSCallHelper");
     final Method jdbcCallMethod =
wsCallHelper.getDeclaredMethod("jdbcCall", Class.class, Object.class,
String.class,
             Object[].class, Class[].class);
     boolean parametersAsUnicode = (Boolean) jdbcCallMethod.invoke(null,
             SQLServerConnectionPoolDataSource.class,
             _dataSource,
             "getSendStringParametersAsUnicode",
             (Object[]) null,
             (Class[]) null);

This code correctly returns the value of the SendStringParametersAsUnicode
datasource property.

I don't think WAS is yet supporting the unwrap method on the DataSource.

> Cross posted in SQL Server Data Access forum at
> http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/7a017a82-03d2
-483f-a1da-fdc0402acae0
.
Wes Clark - 25 Jun 2009 17:29 GMT
On May 29, 10:17 pm, Wes Clark <WesCl...@discussions.microsoft.com>
wrote:
> I got it to work:  Either using the officially WAS 7.0.0.3 supported MS 1.2
> JDBC driver, or the not-yet-supported 2.0 MS JDBC driver, this approach
[quoted text clipped - 20 lines]
> > Cross posted in SQL Server Data Access forum at
> >http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/7a....

Just FYI, IBM says WAS 7.0 should support the Wrapper interface
methods in JDBC 4.0 and the MS 2.0 driver, so I have an open PMR to
resolve this.
Wes Clark - 25 May 2009 05:12 GMT
Posted on developerWorks > WebSphere > Forums > IBM WebSphere Portlet Factory
- Databases and Data Sources >
(https://www.ibm.com/developerworks/forums/thread.jspa?threadID=263671)

Calling SQLServerDataSource method through WSJdbcDataSource

Posted: May 24, 2009 09:06:47 PM.  I have created a WAS 7.0 data source
using the Microsoft 2.0 JDBC driver. The connection pool is working. I need
to call the getSendStringParametersAsUnicode() method on the
SQLServerDataSource object wrapped by the pool to confirm this parameter is
set correctly. From within my applet code:

final Class<?> wsCallHelper = Class.forName
("com.ibm.websphere.rsadapter.WSCallHelper");
final Method jdbcCallMethod = wsCallHelper.getDeclaredMethod("jdbcCall",
Class.class, Object.class, String.class,
Objecthttp://].class, Class[.class);
boolean parametersAsUnicode = (Boolean) jdbcCallMethod.invoke(null,
SQLServerDataSource.class,
_dataSource,
"getSendStringParametersAsUnicode",
(Object[]) null,
(Class[]) null);
System.out.println("parametersAsUnicode: " + parametersAsUnicode);
if (usingUnicode && !parametersAsUnicode || !usingUnicode &&
parametersAsUnicode) {
throw new
DBException(PLDisplayKeys.Java_Database_DBException_InvalidSendParametersAsUnicode,
Boolean.toString(parametersAsUnicode));
}
} catch (Exception e) {
...
}

After finally getting this code working, now I get:

5/24/09 8:31:17:924 PDT 0000000a SystemErr R Caused by:
java.sql.SQLException: DSRA9122E: class
com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource does not wrap any objects of type
class com.microsoft.sqlserver.jdbc.SQLServerDataSource.
5/24/09 8:31:17:924 PDT 0000000a SystemErr R at
com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.call(WSJdbcUtil.java:241)
5/24/09 8:31:17:924 PDT 0000000a SystemErr R at
com.ibm.websphere.rsadapter.WSCallHelper.jdbcCall(WSCallHelper.java:297)

This is the same error I got when I tried to call the unwrap() method on the
DataSource returned by the JNDI call. I'm out of thinghs to try to get this
to work. How can I check the state of the SendStringParameterAsUnicode on the
SQL Server data source from within my application after getting a reference
to the data source?

> Our ISV application supports using SQL Server with either single byte varchar
> columns, or all nvarchar columns.  We support an internal connection pool
[quoted text clipped - 19 lines]
> SendStringParametersAsUnicode in a third-party datasource constructed with
> the Microsoft 2.0 JDBC driver?
Wes Clark - 02 Jul 2009 17:51 GMT
IBM said trying to unwrap a WebSphere DataSource to the underlying
SQLServerDataSource doesn't work because SQLServerDataSource is not an
interface, as specified by the JDBC 4.0 Wrapper JavaDoc for the unwrap
method.  Does Microsoft have plans to provide an "unwrappable" interface to
the SQLServerDataSource so a third party application server DataSource
returned from the JNDI lookup can be unwrapped to allow access to the
SQLServerDataSource methods, such as checking properties such as
SendStringParametersAsUnicode?

I would appreciate a reply from the Microsoft JDBC developer team.  Thanks.

> Posted on developerWorks > WebSphere > Forums > IBM WebSphere Portlet Factory
> - Databases and Data Sources >
[quoted text clipped - 70 lines]
> > SendStringParametersAsUnicode in a third-party datasource constructed with
> > the Microsoft 2.0 JDBC driver?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.