Single jdbc connection opens multiple connections to sql server

Hello!
I'm having a bad problem, because one jdbc connection opens multiple connections to the sql server. I'm working with the open source jdbc driver jtds and the ms sql server. Because I'm using temporary tables that are only visible to one database connection, my code doesn't work. Is this a bug in jtds or is this the normal behaviour of a java.sql.Connection?
Here a code example:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
conn = DriverManager.getConnection(
"jdbc:jtds:sqlserver://"+dbConnDef.getServer()+"/"+dbConnDef.getDatabase(),
dbConnDef.getUserName(),
dbConnDef.getUserPasswd()
Statement stmt = conn.createStatement();
stmt.executeUpdate("SET DATEFORMAT YMD");
stmt.close();
stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE #tmp (FieldA INT NOT NULL)");
stmt.close();
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM #tmp");
stmt = conn.createStatement("SELECT FieldA AS sthElse FROM #tmp");
ResultSet rs2 = stmt.executeQuery("SELECT * FROM #tmp");
// the strange thing is, that this second query does NOT yet open a
// new connection, but the next sql command does.
stmt = conn.createStatement();
stmt.executeUpdate("DROP TABLE #tmp");
stmt.close();
Why is it behaving that strange way? It is absolutely necessary, that EVERYTHING that I do with my connection is really done on the same connection to the SQL server! How can I force a java.sql.Connection not to open multiple sql-server-connections?
It is very urgent, thus, PLEASE HELP!!!
Thousand thanks in advance! Marco.

...but that means, that the jdbc driver I use, is not working properly, because it should work the following way (please correct me, if I misunderstood the concept):
I create a Connection object which should represent exactly one physical connection to the database. Then I can create as many Statement instances by conn.createStatement() as I want. There should still exist only one physical connection.
With each of my Statement objects, I can create one result set.
This means, I should be able to create as many result sets as I want to with only one Connection object (and therefor one physical connection) by creating multiple Statements, right?!
If this is correct, the concept is perfect for me and exactly as I'm used to it by other programming languages. Then, only my jdbc driver does not work properly which means I either have to replace it by another one or change it myself (it's open source).

Similar Messages

  • Can we open multiple connections to APNS Feedback Server

    Hi,
    Is it recommended/allowed to open multiple connections to APNS feedback server to poll the bad tokens?
    The idea is to run a timer task (every hour) on a n application server which will poll the apns feedback server to retrieve the bad tokens and then close the connection every one hour from N app srevers.
    If it is allowed, can multiple parallel connection get the same bad device tokens connected/read at same time?

    You are literally correct in that IP addresses can be spoofed.
    But the same argument can be made about any single, known, form of security.
    If I know it is the fingerprint from your left index finger that is required ... I've no doubt I can break in if I want to badly enough. Sorry about the finger.
    Security comes from layering multiple, unknown, security measures.
    Mix invited nodes with a known userid
    SELECT sys_context('USERENV', 'OS_USER') FROM dual;
    and the hacker has to know both a valid IP address and who is supposed to be there.
    Now on top of that add the operating system information:
    SELECT sys_context('USERENV', 'TERMINAL') FROM dual;
    and it becomes a bit more difficult.
    Layer on a few more and it becomes exceedingly unlikely anyone will get in that doesn't belong there.

  • Remote Connection from SAP to MS-SQL server

    Hello Experts,
    We have been following 2 options so far and we have come across some issues
    The first Option is to call a stored procedure (this is our preferred method) which does the data transfer for us
    We have been able to test this scenario successfully from SQL Server side
    However, while calling the stored proc via native SQL from ABAP we have come across an issue which is due to SQL 2005 changes (Schema implementation and difference in the security context)
    While calling the stored procedure from the ABAP Code we have an error
                The program short dumps with runtime error DBIF_DSQL2_SQL_ERROR, exception CX_SY_NATIVE_SQL_ERROR. The database error code is 15274, and the error text is
                 "Access to the remote server     is denied because the current security context is not trusted."
    This issue is new after the SQL Server 2005.
    We are trying to resolve that.
    Secondly we have been trying the DBCON option as well as per OSS Note 323151
    We have a few things thatu2019s impacting our scenario:
    The remote servers are in a different domain
    The remote servers are located  in DIZ
    Remote server is a named instance
    Remote server has been configured with a different port than standard (1565) u2013 All Connection strings will need port in there
    The Database name starts with a numeric value
    Due a combination of factors as mentioned above the standard approach does not work
    Have any of you used this approach while connecting from SAP to MS-SQL server? Do you know of any successful methods to connect to SQL using ABAP (or not) from SAP.
    Thanks in advance,

    Yes,
    DBConnect & UDConnect.
    Works like a charm.
    We write data into a MS-SQL database via DBConnect & an ABAP program (using open sql).

  • How can I connect NetBeans 6.1 with SQL Server 2005?

    Hello guys...
    how can i connect NetBeans 6.1 with SQL Server 2005?
    there is no SQL Server in Server list when we create a new Web Project and choose Server.
    I'm new to NetBeans and this is my first time of posting.
    If has some errors and unwanted disturbing,pls understand me. Thanks.
    (If you have references or some snippets, i'll be glad if u can share.)
    scsfdev

    The JDBC-ODBC bridge wasn't recognizing any of the primary keys I had set up in SQL Server. After lots of head banging, here's the solution I came up with:
    1. Download the appropriate driver. SQL Server 2000 requires the SQL Server 2000 JDBC driver (http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en).
    SQL Server 2005 download: (http://www.microsoft.com/downloads/details.aspx?familyid=C47053EB-3B64-4794-950D-81E1EC91C1BA&displaylang=en)
    3. After installing, right-click on "Libraries" in your project, and choose "Add Library...". Next, give it a name (i.e. SQLServer2000), and select "Class Libraries".
    4. On the next screen, find the JAR files (should be in C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\), and add them under the "Classpath" tab. It will now be available under "Libraries" for future projects.
    5. You can now create a connection to a specific database under the "Services" tab (next to "Projects" and "Files" in the top left of the screen). Select "Microsoft Sql Server 2000 (Microsoft Driver)" and format the "Database URL" like this:
    jdbc:microsoft:sqlserver//YOURSERVER:1433;DatabaseName=YOURDATABASE
    1433 is the default port, though your DBA may have changed it.
    I posted a simpler version of this on the NetBeans.org FAQ page - they had the following title with no content on the answer page:
    "Cannot Select Tables From MsSql 2000 Because It Says No Primary Key Next To Each Table But The Tables DO Have A Primary Key. What Do I Do?"

  • Connect Oracle Reports to Ms Sql Server DB

    Is it possilbe to Connect Oracle Reports to Microsoft Sql Server database. If yes then how. Please advice.
    Thanks
    Sami.

    It is possible to connect Oracle database to MS Sql server database using the Oracle Transparent Gateway for MS SQL Server.
    You can use the following links to configure such connection:
    Oracle Transparent Gateways - General Description - Part I
    http://oracle-apps-dba.blogspot.com/2008/04/oracle-transparent-gateways-general.html
    Oracle Transparent Gateway for MS SQL Server - Part II
    http://oracle-apps-dba.blogspot.com/2008/04/oracle-transparent-gateway-for-ms-sql_16.html
    Aviad

  • Cannot connect to database master at SQL server at SERVERNAME

    I have installed SQL 2008 R2 in a fresh win 2008 R2. I’m running the sharepoint configuration Wizard using the database server name with the correct domain
    credentials but I get the following error message. “Cannot connect to database master at SQL server at
    SERVERNAME. The database might not exist, or the current user does not have permission to connect”
    I‘m able to login to the new SQL server using the “SQL server management studio” with no problems. I used the sa account and a domain account.
    The sharepoint server is also a new installation. And both servers have the firewall disabled.
    Thanks in advance for your help.
    Simon

    Hi,
    What is your SharePoint server’s version?
    Please make sure you use the farm admin account to launch SharePoint configuration wizard. If not, please log in with this account, then check the effect.
    In addition, check if you create a named instance, such as, servername\sharepoint, however, you only specify the servername in the configuration wizard. If this is
    the case, change to servername\sharepoint, then check the effect.
    Thanks,
    Rock Wang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Regards, Rock Wang Microsoft Online Community Support

  • HOW TO OPEN MULTIPLE TABLES IN SQL DEVELOPER SIMULTANEOUSLY

    hello i m new to sqldeveloper so plz dnt laugh if m asking silly question
    HOW TO OPEN MULTIPLE TABLES IN SQL DEVELOPER SIMULTANEOUSLY

    Use the 'pin' on your table editor
    http://www.thatjeffsmith.com/archive/2011/11/sql-developer-quick-tip-pin-query-result-sets-and-plans/
    Then open your 2nd table. If you want to see both at the same time, right-click on the table editor tab and select 'New Editor Tab Group'
    Not a silly question, but no need to shout :)

  • Connect Oracle Forms 6i with Sql server

    Plz tell how to connect oracle Developer 6i with Microsoft Sql Server 2005.
    thanks

    Ghulam Yassen wrote:
    Plz tell how to connect oracle Developer 6i with Microsoft Sql Server 2005.
    thanksOracle Forms is best used against an Oracle database... so why on Earth would you want to use it against SQL Server?
    Aside from that, Oracle Forms is old technology... you'd be better using Oracle Application Express (Apex) for producing web based apps.
    If you must do things against an SQL Server database, you would need to set up heterogenous services connectivity (HS) and treat the SQL Server database as an external database.
    http://docs.oracle.com/cd/E11882_01/server.112/e25494/ds_concepts001.htm#ADMIN12079

  • How to open sdf files in SQL server 2012?

    How to open sdf files in SQL server 2012?
     I couldn’t figure out how to open the sdf files in SQL server 2012
     Thank you
     Best
     Jamal

    I don't think it's hard if understood the question properly you can try this I do it most of the time and this might be the solution for you, sometimes minor simple click is a life saver:)
    1. 
    Open SQL Server Management Studio, or if it's running select File -> Connect Object Explorer... and click the
    connect drop down arrow
    2. 
    In the Connect to Server dialog you will see Database Enghine, Analaysis Servie on so on and you go head change Server type to
    SQL Server Compact Edition
    3. 
    From the Database file drop-down as shown below click the drop down arrow and select <
    Browse for more...>
    4. 
    And you will see C:\, D:\, G:\
    drive and so on and open, your SDF file where it is located
    I hope this has been informative for you and good luck
    Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer

  • Install Multiple Instance of sql server

    Hi guys,
    I have one question. How can i install multiple instance in sql server ( I am using 180 days VHD to access sql server r2 standard edition). I am accessing sql server through Hyper-V Manager. Can anyone guide me please.
    Regards,
    Jagan

    Hello Jagan,
    For each instance you have to run the SQL Server installer and assign a unique instance Name during Installation; for each instance the Installation procedure is the same.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Open (.sdf) file with SQL server 2005 Management Studio

    In VS2005, I have created a SQL Mobile database, (.sdf).
    Copied that (.sdf) file to Desktop, and when I try to open with SQL Server 2005 management studio, its showing error "make sure the application for the file type (.sdf) is installed."
    How can I open this file with SQL server?
    Regards
    Abinash

    You must install SP2 if using Management Studio Express (http://www.microsoft.com/downloads/details.aspx?familyid=6053C6F8-82C8-479C-B25B-9ACA13141C9E&displaylang=en)Erik Ejlskov Jensen, MCTS: WM App, MCITP: SQL 2008 Dev - http://erikej.blogspot.com
    Please mark as answer, if this was it.

  • Problems upgrading to JDBC 5.1 driver for MS SQL Server

    Hi,
    I recently upgraded to the Weblogic JDBC 5.1 driver for MS SQL Server and I am
    now receiving exceptions in my application when attempting to execute a prepared
    statement. I was previously using the Weblogic JDBC 4.x driver for MS SQL Server
    and everything was working fine without any problems. For some reason I am receiving
    a java.lang.CloneNotSupportedException using the new driver. I am using the setLong(),
    setString(), and setObject() methods of the PreparedStatement and then attempting
    to execute. The application code has not changed, so it seems that something
    has changed in the new driver implementation. Has anyone else had this problem
    or know a work around? Here is a snippet of the actual exception:
    S2 [09/30/02 10:46]: java.sql.SQLException: java.lang.CloneNotSupportedException
    : Error in TdsParameter clone: cannot make duplicate of Stream object
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsPreparedInputStream
    .<init>(TdsPreparedInputStream.java:99)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.doEscapeP
    rocessing(TdsStatement.java:1317)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.execute(T
    dsStatement.java:173)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.executeUp
    date(TdsStatement.java:94)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.executeUp
    date(TdsStatement.java:1438)
    Thanks, Nadeem.

    Nadeem Khokhar wrote:
    Is it true that the Weblogic jDriver for MS SQL Server is deprecated? That's the
    message that I got from BEA Support and here is the link they sent:
    http://edocs.bea.com/wls/docs70/mssqlserver4/install_jmsq4.html#415356
    It recommends using Microsoft's JDBC driver instead. Any thoughts on this? From
    what I understand and what I have read on the newsgroups, the Microsoft JDBC driver
    is still quite buggy and has numerous problems.
    Thanks, Nadeem.It is deprecated, but still supported, and is more recent in the download than the one in
    the 5.1 server. We do recommend MS's driver, or that of www.inetsoftware.de. The
    MS driver is fairly stable now, and may certainly have bugs, as does our driver. The MS
    driver is good because it is not deprecated, and supports JDBC 2.0 etc.
    Joe
    >
    >
    Joseph Weinstein <[email protected]> wrote:
    What version of 5.1? You should be running with the latest service pack.
    If that doesn't help, please download the latest 5.1 driver from our
    site, and
    make sure it's in the weblogic.classpath ahead of all other stuff, by
    editting the
    startWeblogic script.
    Joe
    Nadeem Khokhar wrote:
    Hi,
    I recently upgraded to the Weblogic JDBC 5.1 driver for MS SQL Serverand I am
    now receiving exceptions in my application when attempting to executea prepared
    statement. I was previously using the Weblogic JDBC 4.x driver forMS SQL Server
    and everything was working fine without any problems. For some reasonI am receiving
    a java.lang.CloneNotSupportedException using the new driver. I amusing the setLong(),
    setString(), and setObject() methods of the PreparedStatement and thenattempting
    to execute. The application code has not changed, so it seems thatsomething
    has changed in the new driver implementation. Has anyone else hadthis problem
    or know a work around? Here is a snippet of the actual exception:
    S2 [09/30/02 10:46]: java.sql.SQLException: java.lang.CloneNotSupportedException
    : Error in TdsParameter clone: cannot make duplicate of Stream object
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsPreparedInputStream
    <init>(TdsPreparedInputStream.java:99)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.doEscapeP
    rocessing(TdsStatement.java:1317)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.execute(T
    dsStatement.java:173)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.executeUp
    date(TdsStatement.java:94)
    S2 [09/30/02 10:46]: at weblogic.jdbcbase.mssqlserver4.TdsStatement.executeUp
    date(TdsStatement.java:1438)
    Thanks, Nadeem.

  • Free JDBC 4.0 driver for Microsoft Sql Server database

    Is there any free JDBC 4.0 driver for Microsoft Sql Server database? The jTDS driver is JDBC 3.0 driver. http://jtds.sourceforge.net/

    Sooooooo...
    what's wrong with the driver provided by Microsoft themselves? Which is JDBC 4. And free.

  • Need solution for opening multiple connection to server in parallel

    Hi..
    I have used URL and URLConnectin classes to open connection to server,
    and i used URLConnection.getInputStream( ) to download HTML pages.
    Now my requirement is to open more than one connecton to single HTML document and download the file in parallel.
    for example, if the HTML file size is 60KB..then i open three connection and
    connection 1 downloads first 20KB
    connection 2 downloads second 20KB
    connection 3 downloads final 20KB
    all the above should be done in parallel....by threading or else..
    first of all i want to know is it possible to do the above in java?
    anybody having solution for the above requirement?
    venu

    hi,
    i too have the same problem
    actually i am designing a download manager ,and had the same problem
    that how to put multiple threads for doing it ,,,,
    have u got solution for it..
    if so please help me..
    my mail id is [email protected]
    i want help in designing the download manager
    can any one help me out plzzzzzzzzzzzzzz
    bye

  • JDBC Connectivity - broken pipe received when SQL server resets the connect

    Hi,
    We have downloaded MICROSOFT SQL SERVER 2000 DRIVER for UNIX boxes
    when i try to connect using JDBC , with all parameters
    user id, driver, password etc
    at the sniffer(TCPIP) level when the jdbc connection is attempted
    i see a
    1) SYN packet to the SQL server from unix box
    2) ACK SYN from the SQL server to unix box
    3) ACK from unix box to server
    4) no activity for about a minute
    5) a RST( reset ) from SQL server to unix box.
    at this point i get the following
    stack trace
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Broken pipe or
    no reader on socket
    at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.submitRequest(Unknow
    n Source)
    at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Sou
    rce)
    at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S
    ource)
    at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
    at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java, Compiled Cod
    e)
    at java.sql.DriverManager.getConnection(DriverManager.java, Compiled Cod
    e)
    at wu.database.WUDBAccess.getGiftGramConnection(WUDBAccess.java, Compile
    d Code)
    at wu.util.GiftMailClient.ConnectToDB(GiftMailClient.java, Compiled Code
    at wu.util.GiftMailClient.ProcessEmail(GiftMailClient.java, Compile
    the sniffer trace
    Frame source = (Network)
    Length = 66
    Time received = 09/24/2002 21:19:42.543
    Frame Relay
    Header = 1041
    0001 00.. 0100 .... = DLCI 68
    .... ..0. .... 000. = (Command)
    EtherType = 0800 IP
    Internet Protocol (IP)
    Source address = unix_server
    Destination address = SQL_server
    Type of service = 00
    Length = 60
    Identification = 58024
    Flags = 0000 (May fragment, Last fragment)
    Time to live = 28
    Protocol = 6 TCP
    Transmission Control Protocol (TCP)
    Source Port = 2175
    Destination Port = 8072
    Sequence = 2690569244
    Acknowledgement = 0
    Flags = 02 (SYN)
    Window size = 8192
    ============================= Frame Number 7 =============================
    Frame source = (User)
    Length = 66
    Time received = 09/24/2002 21:19:42.544
    Frame Relay
    Header = 1041
    0001 00.. 0100 .... = DLCI 68
    .... ..0. .... 000. = (Command)
    EtherType = 0800 IP
    Internet Protocol (IP)
    Source address = SQL_server
    Destination address = unix_server
    Type of service = 00
    Length = 60
    Identification = 47302
    Flags = 4000 (Don't fragment, Last fragment)
    Time to live = 126
    Protocol = 6 TCP
    Transmission Control Protocol (TCP)
    Source Port = 8072
    Destination Port = 2175
    Sequence = 60776554
    Acknowledgement = 2690569245
    Flags = 12 (ACK, SYN)
    Window size = 17520
    ============================= Frame Number 8 =============================
    Frame source = (Network)
    Length = 58
    Time received = 09/24/2002 21:19:42.607
    Frame Relay
    Header = 1041
    0001 00.. 0100 .... = DLCI 68
    .... ..0. .... 000. = (Command)
    EtherType = 0800 IP
    Internet Protocol (IP)
    Source address = unix_server
    Destination address = SQL_server
    Type of service = 00
    Length = 52
    Identification = 58025
    Flags = 0000 (May fragment, Last fragment)
    Time to live = 28
    Protocol = 6 TCP
    Transmission Control Protocol (TCP)
    Source Port = 2175
    Destination Port = 8072
    Sequence = 2690569245
    Acknowledgement = 60776555
    Flags = 10 (ACK)
    Window size = 8192
    ****************************************************8
    ============================= Frame Number 9 =============================
    Frame source = (User)
    Length = 52
    Time received = 09/24/2002 21:21:35.137
    Frame Relay
    Header = 1041
    0001 00.. 0100 .... = DLCI 68
    .... ..0. .... 000. = (Command)
    EtherType = 0800 IP
    Internet Protocol (IP)
    Source address = SQL_server
    Destination address = unix_server
    Type of service = 00
    Length = 40
    Identification = 47451
    Flags = 4000 (Don't fragment, Last fragment)
    Time to live = 126
    Protocol = 6 TCP
    Transmission Control Protocol (TCP)
    Source Port = 8072
    Destination Port = 2175
    Sequence = 60776555
    Acknowledgement = 623322721
    Flags = 04 (RST)
    Window size = 0
    Data (ASCII)
    0000 = 00 00 00 00 00 00 ......
    any help is welcome
    Regards,
    Sunil

    Well then, it beats me. I don't see what the problem could be in this case. :o(
    Get another driver and see what happens. I would recommend jTDS, because I'm one of the developers and I can help you debug it. It only supports basic things (such as forward-only result sets, prepared statements and callable statements) but it should be enough to see if you can connect to SQL Server. The address is http://jtds.sourceforge.net
    Alin.

Maybe you are looking for

  • CS6 too small on Surface 3 device

    I just purchased a Surface 3.  Very happy with the device, but bought it because it touted being able to run Photoshop.  I installed CS6 and the icons are too small to read!  I noticed that Creative Cloud has a new option in Preferences called "Exper

  • Why won't the Mac Mini connect to the internet but won't browse

    Here's an odd one...I hook up the mini with an ethernet cable to the cable modem - it finds the settings on it's own - IP address, subnet - the whole thing. That's just great - go to the activity monitor - and look at the network - packets going and

  • Accounting document - "Disc. Base" field (BSEG-SKFBT)

    Hello, In the accounting document, when I click on the customer account (first line item) it opens a screen with "Additional details" sub tab and "Disc. Base" field (BSEG-SKFBT). What is the purpose of this field? How do we control entry into this fi

  • How to use the backup database to create report or update testing

    Hi, I have a fully backup of production database in the last month, and I have using Oracle 8.1.7. I want to known how can I use this backup to generate a new instance so that I can reproduct some report from the last month data or doing some update

  • How do I get the feature to restrict a search to Australian websites please?

    I recently upgraded to Firefox 4 .0 and in the process I lost the option to search either world-wide or 'Australian websites only' which previously used to appear in the centre of the page. Also now I have to go to the top right of the page in the se