8 Replies Latest reply on Dec 19, 2004 12:32 PM by Alexey Loubyansky

    JDBC Insert Data Not Commited

    Auzi Auzi Newbie

      Hi,

      I have an application that uses simple
      JDBC to work with the database.
      The application executes simple INSERT\SELECT
      statements, using prepared statements.
      I'm using a MS-Sql local-tx datasource to get
      the connection.
      For some reason the table I'm working with gets
      locked right after I perform an insert, and it is not
      freed, when I do a select after insert, the select
      "hangs".
      My mssql-ds.xml file has the following:

      <local-tx-datasource>
      <jndi-name>MyDs</jndi-name> <connection-url>jdbc:microsoft:sqlserver://mypc:1433</connection-url>
      <connection-property name="DatabaseName">
      mydb
      </connection-property> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <user-name>xx</user-name>
      yy
      <min-pool-size>2</min-pool-size>
      <max-pool-size>10</max-pool-size>
      <idle-timeout-minutes>0</idle-timeout-minutes>
      <blocking-timeout-millis>5000</blocking-timeout-millis>
      <track-statements>true</track-statements>
      </local-tx-datasource>

      My code uses the following:

      InitialContext ctx = InitialContextUtil.getContext();
      DataSource ds = (DataSource) ctx.lookup("MyDs");
      Connection con = ds.getConnection();

      I get no errors during execution, however, after the insert,
      every select on the same table either from within jboss or from
      MS query analayzer hangs (queries on other objects work ok).

      thanks,
      Auzi