on 12-01-2005 6:26 PM
Hi,
I am trying to write a session bean that runs a query
against a JDBC system, but I keep seeing the following
error in the default trace file in the J2EE log folder:
14##0#0#Path##Java###Throwing
#1#java.sql.SQLException: Invalid connection string
attribute: Database name is required but not supplied#
#1.5#
This is the code, with the line marked (*) being the point where the exception is thrown:
public void getConnection(String sURL, String sUser, String sPassword) {
ManagedConnectionFactory mcf = null;
IConnectionFactory cf = null;
IConnectionSpec cs = null;
try {
mcf = new JDBCManagedConnectionFactory();
cf = (IConnectionFactory) mcf.createConnectionFactory();
cs = cf.getConnectionSpec();
cs.setPropertyValue("UserName", "sa");
cs.setPropertyValue("Password", "admin");
cs.setPropertyValue"driver",
"com.sap.portals.jdbc.sqlserver.SQLServerDriver");
cs.setPropertyValue("url",
"jdbc:sap:sqlserver://localhost:1433;DatabaseName=pubs");
conn = cf.getConnectionEx(cs); (*)
I have tried adding another property value, like so:
cs.setPropertyValue( "DatabaseName", "pubs");
(or) cs.setPropertyValue( "Database", "pubs" );
but I still get the same exception. What does this
exception really mean, what is missing from the
configuration information ?
Also, in the default trace file of the J2EE engine, the
configuration information is printed out, but in an
encrypted format, (see below), is it possible to have it
print out this information in a readable format ?
#1.5#005056A41E66006200000092000009AC000406E03C94F3D9#1133460065906#com.sap.portal.connectors.JDBC#sap.com/CFV3#com.sap.portal.connectors.JDBC#Guest#0####71758520629411daacf7005056a41e66#SAPEngine_Application_Thread[impl:3]_14##0#0#Info##Plain###UserName: ????n????????????????????d?????????????????????????????????????????????s???????????????????????????????????????????????0??????????????????????????????????????????????????h?????0??????R???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????s?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????c???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????u??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????c???????????????????????????????????????????c????????????????3?????????3????e??????????????????????????????????????????????????l???????0????????1????1?????????????????????????????????????????????????????????s?????p?????????????????????????????????????????????????????????????????6?????????????3??????????????s????????????????????t???????????s????????????????????????????????????????????????????????????????????????s????????????????????????????????????????????????????????s?????????????????????????????????g????????????????????????????????????????????????????????????????????????? Password: ******** URL: ???????????????n??????????????????????????????????????????????????????????????????????????0?????e??????????????????????????r?????????????s?????????????O??????????????2???????????7????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????:????5???T?????????????????????????l?????????1????????????????????????????????????????????????????????????????????????????2??????????????????????????????????????????????????????????????????????????????????????????????????h???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????a??????????????????????????????????????????????????????????????????????????????????????????????????S??????????????????????????????????????????????????????????????????????????????????2???????????????????????????u???????????????????????????????????????????????????????????????????????s???????????????????????????????????????????????????????????????????????????????????????????????s?????????????????????????????????????????.?????????????????????????????????????????????????????????????????1????????????????????????????????????l????5??????????? Driver: com.sap.portals.jdbc.sqlserver.SQLServerDriver#
#1.5#0
Hi Colm,
I don't understand why you want to use JCA to connect to a database? For this purpose you have a specially designated, clean and powerful JDBC API. You can declare a resource reference for your session bean to the datasource and use the DataSource instance to get connection and run queries against the database. Have a look at the <a href="http://help.sap.com/saphelp_nw04/helpdata/en/82/fdbf2085f65f43a71e755fc904478d/frameset.htm">documentation</a>.
Hope that helps!
Vladimir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vladimir,
thanks for your response. The reason I am accessing a
JDBC source via JCA is to get a feel for how JCA works.
What I ultimately want to do is construct a bean that can
give queries to different kinds of sources; JDBC, and SAP
(R3, CRM), and possibly sources like Siebel. For this, I
believe I should use the Connector Gateway Service, as
described in the "Using the JDBC Connector" and "Using
the SAP Backend System Connector" sections of the SAP
Portal Developer's Guide. But for now, my first approach
was to use the approach described in "Connecting via
J2EE" subsection of "Using the JDBC Connector" (see
http://help.sap.com/saphelp_nw04/helpdata/en/30/a0f17aacb34b108b39a96acc33da3f/content.htm)
Thanks,
Colm.
Hi Colm,
OK, I understand that. What I don't understand is why you are looking into the Portal Developer Guide and using Portal APIs when you are developing an EJB? I guess more appropriate would be to have a look at and leverage the <a href="http://help.sap.com/saphelp_nw04/helpdata/en/97/fabc3d8af79633e10000000a11405a/frameset.htm">J2EE Connector Architecture</a> implementation in the J2EE Engine.
Best regards,
Vladimir
PS. Please consider rewarding points for helpful answers.
Hi Vladimir, I have considered developing a resource adapter for what I need to do, but thought that using the Connector Gateway service of the Portal would be a quick way to prototype my program; if the J2EE connector architecture provided a SAP Connector service, I would use that, but as far as I know, the Connector Gateway Service in the Portal is the only service that provides access to such a service.
Thanks,
Colm.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.