Problem creating SQL commands in JDBC

I want to send the following seemingly very simple SQL statements to the mysql server via JDBC inside a servlet:
querry1: SELECT * FROM japeng_math WHERE (kanji='userInput' OR kana='userInput')
querry2: SELECT * FROM majors WHERE major='majorcode'     
userInput and majorcode are variables of type String. They are assigned values before using in the SQL.
I coded the commands as follows:
querry1 = "select * from japeng_math where (kanji=" + "'" userInput "'" + "or kana=" + "'" userInput "'" + ")" ;
System.out.println("querry 1: " + querry1);
querry2 = "select * from majors where major=" + "'" + majorcode + "'";
System.out.println("querry 2: " + querry2);
I can't find what is going wrong here, but I'm not getting the desired strings for querry1 and querry2.
I found that error in querry string occurs only when two-byte Japanese characters (which is the commone case) are input.
Here is the output at console:
1. when a two-byte Japanese character was input in the form field
querry 1: select * from japeng_math where (kanji='���a'or kana='���a')
'uerry 2: select * from majors where major='geom
(There is an apostrophe in place of q of querry. And also major='geom. But the expected value should have been : major='geom')
2. when single-byte (hankaku) Japanese character was input
querry 1: select * from japeng_math where (kanji='����'or kana='����')
querry 2: select * from majors where major='geom'
(both OK)
3. when English was input, both OK.
I'm stuck. Please help. How can I make it work seamlessly, without worrying what type of charcters are input?
By the way, my database & server setting are in Shift-JIS. I've also converted the input string to Shift-JIS in the program
before using it.
Thank you very much.

>
I'm stuck. Please help. How can I make it work
seamlessly, without worrying what type of charcters
are input?Characters in java are in unicode.
When you display characters, such as when System.out is used, the unicode is converted into something else.
Similarily when you go through the JDBC interface they are converted to something else.
And depending on the source of the characters they might not be unicode to start with.
So the first step is to determine that the input strings actually contain the characters that you expect. The only way to do that is to print each character as an integer (hex format) and then look it up in a unicode chart to determine that it is the correct character. Until you do this you there is no point in trying anything else.
Once you determine this then the next step is to use a PreparedStatement to create the SQL. This might work. Or it might not. You should read the following thread including the links posted there ....
http://forum.java.sun.com/thread.jsp?forum=48&thread=407345

Similar Messages

  • How to echo the SQL command in JDBC?

    When we use a PreparedStatement and execute query, is there a way to get the exact SQL command
    sent to the server without any '?' marks? That would be an aid in debugging. Or is such a facility server-pecific? I am using MySQL with JDBC.
    Thank you.

    Why I want to see the SQL command now is that I am getting a nagging SQLException in the following
    code. Would someone tell me why this code fails?
    //Database connection successful.
    //conn and pstmt are successfully created.
    //variables 'pid' and 'subfolder' are already evaluated, and confirmed that they have valid values
    int sub_id = 0;
    String myquery = null;
    ResultSet rs1 = null;
    try{
    myquery = "SELECT j15c_directory_id FROM j15t_directory WHERE (j15c_parent_id = ? AND j15c_name = ?)";
    pstmt = conn.prepareStatement(myquery);
    pstmt.setInt(1,pid);
    pstmt.setString(2,subfolder);
    rs1 = pstmt.executeQuery();
    rs1.next();
    sub_id =rs1.getInt("j15c_directory_id");
    catch(java.sql.SQLException e1){
    System.err.println("SQLException: " + e1.getMessage());
    The error message I'm getting is "Before start of result set ".

  • Problem with delete command through JDBC

    hi all,
    I have the following code in a Java program
    try
    DriverManager.registerDriver
    (new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@localhost:1521:orcl", "airport", "airport");
    catch (SQLException ex)
    ex.printStackTrace();
    Every statement works fine except the delete command. When i try to execute this statement:
    stmt = conn.createStatement();
    stmt.executeUpdate("DELETE FROM distances");
    the program stalls. The table "distances" is owned by the user airport and this sql command works fine when I execute it in SQL+. The problem occurs when I try to execute a delete command through JDBC.
    Can anyone help me?
    Thanks...

    It seems that the problem ocuurs only when there are pending transactions.Correct. There are uncommitted INSERT/UPDATE/DELETEs on the table. Readers never block writers, thus having opened SELECT cursors on the table is not a problem. You writer process must be blocked by another writer process. (assuming of course no JDBC thin driver error - of which I've heard rumours there are or were quite a few - not using thin JDBC myself, thus cannot comment on whether these rumours are valid or not)
    What I would think a bit concerning is that one application trashing a table (deleting all the data) while other applications/users are busy changing data in that table. Why are they changing data that will be immediately trashed after they have committed their transactions? Surely they are wasting time and resources all around (user-side and server-side) by doing work that will be immediately invalidated? This kind of points to me to a database or application design problem.

  • Error creating SQL Command - Database Expert

    I am creating a command however when I go to save the SQL I get two errors.
    "Failed to retrieve data from database" and "Failed to execute SQL Statement"
    I am working on an Oracle database. 
    Why would these errors be occuring?

    SELECT
    "CI_ACCT_PER"."ACCT_ID", "CI_ACCT_PER"."ACCT_REL_TYPE_CD", "CI_ACCT_PER"."PER_ID", "CI_ACCT_PER"."MAIN_CUST_SW", "CI_ACCT_PER"."FIN_RESP_SW", "CI_ACCT"."ACCT_ID",
    "CI_PER"."PER_OR_BUS_FLG", "CI_PER"."CITY", "CI_PER"."POSTAL", "CI_PER"."GEO_CODE", "CI_PER"."STATE", "CI_PER"."COUNTRY", "CI_PER_NAME"."PER_ID", "CI_PER_NAME"."ENTITY_NAME", "CI_PER_NAME"."NAME_TYPE_FLG", "CI_PER_NAME"."PRIM_NAME_SW",
    "CI_SA"."SA_ID", "CI_SA"."SA_TYPE_CD", "CI_SA"."SA_STATUS_FLG", "CI_SA_REL"."SA_REL_ID", "CI_SA_REL"."SA_ID", "CI_SA_REL"."SA_REL_STATUS_FLG", "CI_SA_REL"."SA_REL_USAGE_FLG", "CI_SA_REL"."SPR_CD", "CI_SA_REL"."SA_REL_TYPE_CD", "CI_SA"."CHAR_PREM_ID",
    "CI_SPR"."SA_ID", "CI_SPR"."PER_ID",
    "CI_PREM"."ADDRESS1", "CI_PREM"."PREM_ID",
    "CI_SA_RS_HIST"."EFFDT", "CI_SA_RS_HIST"."RS_CD"
    FROM ((((((("CISADM"."CI_SA" "CI_SA" LEFT OUTER JOIN "CISADM"."CI_ACCT" "CI_ACCT" ON "CI_SA"."ACCT_ID"="CI_ACCT"."ACCT_ID")
    LEFT OUTER JOIN "CISADM"."CI_SA_REL" "CI_SA_REL" ON "CI_SA"."SA_ID"="CI_SA_REL"."SA_ID")
    LEFT OUTER JOIN "CISADM"."CI_PREM" "CI_PREM" ON "CI_SA"."CHAR_PREM_ID"="CI_PREM"."PREM_ID")
    LEFT OUTER JOIN "CISADM"."CI_SA_RS_HIST" "CI_SA_RS_HIST" ON "CI_SA"."SA_ID"="CI_SA_RS_HIST"."SA_ID")
    LEFT OUTER JOIN "CISADM"."CI_ACCT_PER" "CI_ACCT_PER" ON "CI_ACCT"."ACCT_ID"="CI_ACCT_PER"."ACCT_ID")
    LEFT OUTER JOIN "CISADM"."CI_PER" "CI_PER" ON "CI_ACCT_PER"."PER_ID"="CI_PER"."PER_ID")
    LEFT OUTER JOIN "CISADM"."CI_PER_NAME" "CI_PER_NAME" ON "CI_PER"."PER_ID"="CI_PER_NAME"."PER_ID")
    LEFT OUTER JOIN "CISADM"."CI_SPR" "CI_SPR" ON "CI_SA_REL"."SPR_CD"="CI_SPR"."SPR_CD"
    WHERE "CI_PER_NAME"."PRIM_NAME_SW"='Y'
    AND "CI_ACCT_PER"."MAIN_CUST_SW"='Y'
    AND "CI_ACCT_PER"."FIN_RESP_SW"='Y'
    AND "CI_SA_REL"."SA_REL_STATUS_FLG"='A'
    and "CI_SA_RS_HIST"."EFFDT"<date(2009,1,1)
    ORDER BY "CI_SA_REL"."SPR_CD", "CI_SA"."SA_ID", "CI_ACCT_PER"."ACCT_ID", "CI_ACCT_PER"."PER_ID"

  • Problem with SQL used in JDBC

    I am working on a Code, in which I have to read the input from the MS ACCESS and give the output on the GUI, The problem is that,the First Feild in the MS Access Table is Integer Numbers which is ID of the person, when I execute the Following code using the ID feild in the SQl query it gives me SQL exceptions, but when I used First name feild in the SQL query then It gives me right answer.
    Please tell me where is Am making the mistake, I have some Idea tht it is some thing to do with the ID feild in the SQL query.
    Please Help me.
    // Haroon Usman Chaudhry.
    // CSC 224, section 202
    // Project GradesFromDB
    //Submission Date July 13 2001
    import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MyFrame extends JFrame
    // Instance variables.
    private JTextField id, firstNameText, lastNameText, courseNumberText, courseTitleText, profNameText, creditHoursText, gradeText;
    private JLabel idLabel, firstNameLabel, lastNameLabel, courseNumberLabel, courseTitleLabel, profNameLabel, creditHoursLabel, gradeLabel, extraLabel;
    private JButton first, next;
    private JPanel panel;
    private boolean atEOF;
    String db;
    Connection c;
    Statement s;
    ResultSet r;
    MyListener a;
    public MyFrame() throws SQLException,
    ClassNotFoundException
    super("Grades"); // Set caption in parent constructor.
    setSize(600, 160); // Set the Size of the Panel.
    // Initializing all the Text Feilds
    id = new JTextField(25);
    firstNameText = new JTextField(25);
    lastNameText = new JTextField(25);
    courseNumberText = new JTextField(25);
    courseTitleText= new JTextField(25);
    profNameText = new JTextField(25);
    creditHoursText= new JTextField(25);
    gradeText = new JTextField(25);
    panel = new JPanel(new GridLayout(5, 4, 5, 5)); // Panel Layout is set to GridLayout
    // Initializing the Buttons.
    first = new JButton ("First Grade");
    next = new JButton ("Next Grade");
    atEOF = false;
    // Initializing the Labels for the panel.
    idLabel = new JLabel(" ID");
    firstNameLabel = new JLabel(" First Name");
    lastNameLabel = new JLabel(" Last Name");
    courseNumberLabel = new JLabel(" Course Number");
    courseTitleLabel = new JLabel(" Course Title");
    profNameLabel = new JLabel(" Professor Name");
    creditHoursLabel = new JLabel(" Credit Hours");
    gradeLabel = new JLabel(" Grade");
    extraLabel = new JLabel (" ");
    // Add Contents to the Panel.
    panel.add(id);
    panel.add(firstNameText);
    panel.add(lastNameText);
    panel.add(courseNumberText);
    panel.add(idLabel);
    panel.add(firstNameLabel);
    panel.add(lastNameLabel);
    panel.add(courseNumberLabel);
    panel.add(courseTitleText);
    panel.add(profNameText);
    panel.add(creditHoursText);
    panel.add(gradeText);
    panel.add(courseTitleLabel);
    panel.add(profNameLabel);
    panel.add(creditHoursLabel);
    panel.add(gradeLabel);
    panel.add(extraLabel);
    panel.add(first);
    panel.add(next);
    // Set ContentPane.
    setContentPane(panel);
    // Initializing the ActionListener.
    a = new MyListener();
    first.addActionListener(a);
    next.addActionListener(a);
    // Set up database stuff.
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    db = "jdbc:odbc:GradeData";
    c = DriverManager.getConnection(db);
    public class MyListener implements ActionListener
    public void actionPerformed(ActionEvent event)
    try
    if (event.getSource() == first) // When the First Button is Pressed then Do the Following Code.
    String str = "SELECT * FROM Grades WHERE ID = '" + id.getText()+ "'";
    s = c.createStatement();
    r = s.executeQuery(str);
    if (atEOF = !r.next())
    return;
    else
    // Setting the Feilds for the OutPut.
    firstNameText.setText(r.getString(2));
    lastNameText.setText(r.getString(3));
    courseNumberText.setText(r.getString(4));
    courseTitleText.setText(r.getString(5));
    profNameText.setText(r.getString(6));
    creditHoursText.setText(r.getString(7));
    gradeText.setText(r.getString(8));
    else // When the Next Button is Pressed then Do the Following Code.
    if (!atEOF)
    atEOF = !r.next();
    if (!atEOF)
    // id.setText(r.getString(1));
    firstNameText.setText(r.getString(2));
    lastNameText.setText(r.getString(3));
    courseNumberText.setText(r.getString(4));
    courseTitleText.setText(r.getString(5));
    profNameText.setText(r.getString(6));
    creditHoursText.setText(r.getString(7));
    gradeText.setText(r.getString(8));
    catch(SQLException e)
    System.out.println("SQLException"); // SQL Exceptions.

    Where are you getting the exception.
    Is it the lines you commented out? If so and the id field is numeric try using getInt (or whatever) instead of getString

  • Problem using sql command line

    Hello!
    I do have some problems with using the command line for INSERT statements. When I perform insert statements the data of these statements are lost as soon as I close the command line. Other statements like SELECT or CREATE TABLE work properly.
    any idea?
    regards
    D.

    I do have some problems with using the command line
    for INSERT statements. When I perform insert
    statements the data of these statements are lost as
    soon as I close the command line. Other statements
    like SELECT or CREATE TABLE work properly.
    Have you run "COMMIT", after insert statement ??
    You need to run "commit" (preferable) or exit (Oracle explicit commit on exit).
    You might have close the sqlplus window without running above command.
    See following thread for explanation with example
    Re: commit problem!!
    Virag

  • SQL Command problem in Application Express 3.2.0.00.27

    To Oracle Application Express Development Team,
    Yesterday I installed Oracle Application Express 3.2.0.00.27.
    While doing my r&d, I came across one problem in SQL Command.
    For example I wanted to run sql "select * from tab"
    When I checked "Autocommit" checkbox it worked fine.
    But when I unchecked the "Autocommit" checkbox it gave me following error:
    ORA-01003: no statement parsed
    Please check post
    http://www.oraclebrains.com/2009/03/sql-command-problem-in-application-express-3200027/ for more details.
    Cheers

    I can't find the log file (a good indication that something went wrong)
    Here's the transcript of the session...
    SQL> startup upgrade
    ORACLE instance started.
    Total System Global Area 599785472 bytes
    Fixed Size 1288820 bytes
    Variable Size 264242572 bytes
    Database Buffers 331350016 bytes
    Redo Buffers 2904064 bytes
    Database mounted.
    Database opened.
    SQL> @apxpatch.sql
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    Wrote file apxset.sql
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    SQL>
    SQL> @apxldimg.sql
    PL/SQL procedure successfully completed.
    Enter value for 1: C:\Documents and Settings\jtench\Desktop\My Downloads\Oracle\apex_3.2.1
    old 1: create directory APEX_IMAGES as '&1/apex/images'
    new 1: create directory APEX_IMAGES as 'C:\Documents and Settings\jtench\Desktop\My Downloads\Oracle\apex_3.2.1/apex/images'
    Directory created.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    Commit complete.
    timing for: Load Images
    Elapsed: 00:03:30.03
    Directory dropped.
    SQL>

  • SQL Command newbie problem

    hello,
    i am using cr 2011 and am trying to learn how to create sql commands. this is my first attempt.
    i created an sql command (select distinct region from customer) using the add command to report dialog box.
    i then created a parameter field on the command parameter dialog box.
    i was expecting to see this parameter field in the field explorer like the other parameter fields that i've created using the create new parameter dialog box, but i didn't.
    i ran the report, but the parameter field (for the sql command) did not pop up.
    is this parameter field suppose to work like the other parameter fields?
    i can't figure out what i'm doing wrong. i thought i followed the directions in the help file.
    any help would be greatly appreciated.
    thank you
    tracy

    Hi Tracy,
    Th reason you're not being prompted for the parameter and the reason you don't see it in the Field Explorer is because you actually haven't 'used' it in the command object.
    By creating a parameter at the command level, you're actually passing values to the SQL query. Something like this:
    select name, id from Emp where dept = {?Parameter_Name}
    ...where {?Parameter_Name} is the name of the Parameter you create at the command level.
    Now, you might ask how do I put it in the command object? After you create the parameter, place the cursor at the command line where you wish to pass values. For eg: In my example I expect users to enter values for Department. So, I place the cursor after *where dept = * and then double-click on the parameter name and it automatically comes in there. Or you can even type it the way I did.
    Hope this helps!
    -Abhilash

  • CR XI SQL Command

    Post Author: [email protected]
    CA Forum: Crystal Reports
    Can the floowing SQL statements be executed from a create SQL command within CR XI
    Drop tabe t1
    create table #t1 (field1 varchar 2, field2 varchar 4)
    insert into #t1 (field1, field2)
    select id,acctno from chargeno where amt1 > 0
    insert into #t1 (field1, field2)
    select id,accno from chargeno where amt2 > 0
    select * from #t1
    The information in t1 is what I need to return to CR.  Can you use multiply sql commands within a cr command?
    Thanks

    Hello,
    I reply to my post just to say that I've found a solution.
    I've downloaded CR4E version 2 with the new sdk crjava-runtime_12.2.200.
    I've installed all the new .jars and create a new jsp page on my web server and now the report works fine.
    I have to test this version (12.2.200) before using it on our server.
    But it seems to be a good one.
    Arthuro.

  • Compile a procedure /SQL file using JDBC?

    Is there a way we can compile a procedure or even a smiple SQL file using JDBC?
    Or in other words can "@ <file name with path>" be done using JDBC? Has anyone tried this before?
    I have five different databases, and i want to be able to compile my stored procedures at once on all my 5 databases. So, if we know if this is possible in JDBC?
    THanks

    right, as a matter of fact i wanted some pointers on how to run these SQL commands using JDBC.
    Like, set serveroutput on
    set feedback on
    @ filename or start filename
    show error
    etc.

  • Problem creating a SQL command object and adding it to a Crystal report

    Hi,
    I'm trying to add the following SQL command object with the following sql for MYSQL 5.1
    SELECT lic.id, lic.productionname, comp.companyname, lic.paymentreceiveddate, lic.licenseissuedate,
    IFNULL((SELECT sum(licsong.feequoted) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfeequoted,
    IFNULL((SELECT sum(licsong.feetax) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfeetax,
    IFNULL((SELECT sum(licsong.feequoted + licsong.feetax) from licensesong licsong where licsong.licenseid = lic.id), 0) as totalfee,
    IFNULL((SELECT sum(pay.fullamount) from payment pay where pay.licenseid = lic.id),0) as totalpaid
    FROM license lic
    INNER JOIN company comp on lic.licensecompanyid= comp.id;
    This sql runs fine in the Query Browser of mysql and returns what I want.
    When I try to add this SQL command to a new Crystal Report, (by right clicking in the sql editor and selecting Crystal Reports - Add to new Crystal Report), it locks up my Eclipses and it ends up not responding. If I just do a simple SELECT * FROM license it works fine.
    The Eclipse I'm using is from the CR4E download page with the crystal plugin already installed.
    Any help with this would be greatful, as I am not having much joy with this CR4E 2.0 with MySQL and may have to scrap it and go back creating reports in Apache POI.
    Any help greatly received.
    Kind regards

    Hi,
    Try to select a particular columns instead of doing SELECT * FROM license.
    Thanks,
    Saravanakumar

  • Sender JDBC Communication Update SQL Command Problem!

    Hi all,
    I am trying to do a SENDER JDBC Scenario in XI.
    I fetch the Records from the table Once per day based on the Current Date.
    I do not have any Update Credentials in the table.
    I can only perform Select Querry.
    But when i am trying to configure the SENDER JDBC Channel its asking me to enter value for Update SQL Command in Sender JDBC communication channel Process Parameters.
    Its not accepting BLANK or ' * '  Values.
    But i have only Select Querry credentials in the table. I can only pick the values cant Update the tables but.
    In the Above scenario how can i configure the Sender JDBC CC without Updating the Table after fetching the value?
    Please Advice
    Regards,
    Senthilprakash.

    Hi,
    Specify the Update SQL Statement value as .
    http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
    Thanks
    SaNv...
    Edited by: Sãnthosh Kûmãr  V on Oct 8, 2008 10:44 AM
    Edited by: Sãnthosh Kûmãr  V on Oct 8, 2008 10:45 AM

  • Problem creating an sql query with a parameter which is a list

    Hi,
    Im having a problem creating a certain SQL query.
    The query looks like this:
    SELECT gstock_id FROM germplasm_stock gps, germplasm gp WHERE gps.germplasm_id = gp.germplasm_id AND organism_id IN ($childList:VARCHAR).
    the organism_id field is of DECIMAL type.
    the parameter childList is actually a list of Id's, something like: 123,124,789
    and it is created dynamically by an other function, so I cant just put it there staticlly.
    I tried using the ARRAY type instead of VARCHAR, but that didn't work,
    anyone knows how can I give this query a parameter which is a list of numbers ?
    Thanks

    I have tried all the following options and the same issue occurs:
    EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
    With Parameter: 0, @ChangeVersion, ChangeVersion
    EXEC dbo.uspGetSiteChanges ?
    With Parameter: 0, @ChangeVersion, ChangeVersion
    In my first data flow I use the following and it works on two OLE DB Sources:
    EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
    With:
    In my second data flow task, I use the same command and parameter mappings and it fails, very strange.

  • Problem accessing Sql server Procedure from Crystal with JDBC driver

    I have some Crystal reports using SQL Server procedures, most of them are working very well; however, I have 2 that have problems accessing sql server procedures. These reports are working using OLE DB connection without problem, but when I try to relocate the connection to JDBC Crystal generates an error like that the procedure not return records.
    The procedure is working with other products including OLE DB connections from crystal.
    What can I do?
    Thanks in Advance,
    JaimeC

    I am using:
    Crystal report 11 - 11.0.0.1282 and Crystal 2008 = 12.0.0.683
    SQL Server 2005 -  Microsoft SQL Server Management Studio Express     9.00.4035.00
    Windows XP
    I have discovered that the procedures create and work  temporary tables. In other cases when is working ok, the procedures have not working temporary tables.
    Thanks,
    Jaime Carrillo

  • Problem using production version of SQL Server 2005 JDBC drivers

    A production version of the Microsoft SQL Server 2005 JDBC driver became available on 1/20/06, and we are having some issues getting it to work with WLS 9.1. The non-XA driver works fine, but when we attempt to use the XA version, we see the error below in our logs. (Note that in the text "status:0 msg:null", the "null" is actually an unprintable character that I was not able to copy/paste.)
    We have successfully tested WLS 9.1 with the beta JDBC drivers that were released by Microsoft a number of months ago, so this appears to be a problem with the prod version only (although we had no trouble using the prod drivers with JBoss). We have actually opened a support case for this, but the response we have received thus far has been negligible at best and we really need to get this issue resolved, so I am posting the problem here as well to see if anyone else has encountered it.
    Regards,
    Sabrina
         at ourpackage.OurMDB.onMessage(OurMDB.java:184)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:426)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:332)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:288)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Caused by: ourpackage.OurDBUtil.openConnection(OurDBUtil.java:130)     
         ... 11 more
    Caused by: java.sql.SQLException: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XA_OK start() failed on resource 'OurXADataSource': XA_OK
    javax.transaction.xa.XAException: java.sql.SQLException: Failed to create the XA control connection. Error: xp_sqljdbc_xa_init failure, status:0 msg:null.
         at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(Ljavax.transaction.xa.Xid;I)V(Unknown Source)
         at weblogic.jdbc.jta.DataSource.start(DataSource.java:679)
         at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1160)
         at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1093)
         at weblogic.transaction.internal.XAServerResourceInfo.enlist(XAServerResourceInfo.java:274)
         at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:496)
         at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:428)
         at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1390)
         at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1314)
         at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:436)
         at weblogic.jdbc.jta.DataSource.connect(DataSource.java:392)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
         at ourpackage.OurDBUtil.openConnection(OurDBUtil.java:125)     
         at ourpackage.OurMDB.onMessage(OurMDB.java:184)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:426)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:332)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:288)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
         at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1395)
         at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1314)
         at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:436)
         at weblogic.jdbc.jta.DataSource.connect(DataSource.java:392)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
         at ourpackage.OurDBUtil.openConnection(OurDBUtil.java:125)     
         at ourpackage.OurMDB.onMessage(OurMDB.java:184)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:426)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:332)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:288)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
         at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1327)
         at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:436)
         at weblogic.jdbc.jta.DataSource.connect(DataSource.java:392)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
         at ourpackage.OurDBUtil.openConnection(OurDBUtil.java:125)
         ... 12 more

    SabrinaL wrote:
    A production version of the Microsoft SQL Server 2005 JDBC driver became available on 1/20/06, and we are having some issues getting it to work with WLS 9.1. The non-XA driver works fine, but when we attempt to use the XA version, we see the error below in our logs. (Note that in the text "status:0 msg:null", the "null" is actually an unprintable character that I was not able to copy/paste.)
    We have successfully tested WLS 9.1 with the beta JDBC drivers that were released by Microsoft a number of months ago, so this appears to be a problem with the prod version only (although we had no trouble using the prod drivers with JBoss). We have actually opened a support case for this, but the response we have received thus far has been negligible at best and we really need to get this issue resolved, so I am posting the problem here as well to see if anyone else has encountered it.
    Regards,
    SabrinaHi. Have you done all the XA-related install for the new MS driver? (put the XA
    dll in the DBMS environment etc)? Is your DBMS on a 32-bit machine or 64-bit machine?
    Does the driver present a dll for each of those? You can also get good JDBC help
    from MS via their microsoft.public.sqlserver.jdbcdriver newsgroup.
    Joe Weinstein at BEA
    >
         at ourpackage.OurMDB.onMessage(OurMDB.java:184)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:426)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:332)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:288)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    Caused by: ourpackage.OurDBUtil.openConnection(OurDBUtil.java:130)     
         ... 11 more
    Caused by: java.sql.SQLException: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XA_OK start() failed on resource 'OurXADataSource': XA_OK
    javax.transaction.xa.XAException: java.sql.SQLException: Failed to create the XA control connection. Error: xp_sqljdbc_xa_init failure, status:0 msg:null.
         at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(Ljavax.transaction.xa.Xid;I)V(Unknown Source)
         at weblogic.jdbc.jta.DataSource.start(DataSource.java:679)
         at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1160)
         at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1093)
         at weblogic.transaction.internal.XAServerResourceInfo.enlist(XAServerResourceInfo.java:274)
         at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:496)
         at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:428)
         at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1390)
         at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1314)
         at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:436)
         at weblogic.jdbc.jta.DataSource.connect(DataSource.java:392)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
         at ourpackage.OurDBUtil.openConnection(OurDBUtil.java:125)     
         at ourpackage.OurMDB.onMessage(OurMDB.java:184)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:426)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:332)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:288)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
         at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1395)
         at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1314)
         at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:436)
         at weblogic.jdbc.jta.DataSource.connect(DataSource.java:392)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
         at ourpackage.OurDBUtil.openConnection(OurDBUtil.java:125)     
         at ourpackage.OurMDB.onMessage(OurMDB.java:184)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:426)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:332)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:288)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:3824)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:3738)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4228)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
         at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1327)
         at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:436)
         at weblogic.jdbc.jta.DataSource.connect(DataSource.java:392)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:359)
         at ourpackage.OurDBUtil.openConnection(OurDBUtil.java:125)
         ... 12 more

Maybe you are looking for