Welcome to the SQL Server JDBC blog

Welcome to the SQL Server JDBC blog

  • Comments 79

Unsure of what to specify in the connection URL? Having trouble configuring the driver for Integrated Authentication? Confused about some behavior with the Microsoft SQL Server JDBC driver? Then, this is the blog site for you.

The SQL Server JDBC team maintains this blog.  The team is responsible for all things regarding JDBC with SQL Server.  We hope to use this blog to proactively provide answers to many of the re-occuring issues that we see our customers face.  We will also use this blog to provide some insight into features in planning for future releases.

Hopefully you will find this useful.

SQL Server JDBC team
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights

Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post
  • Glad to see this. I would like to use JPA (Java Persistence API from Hibernate) with SQL Server Express edition. Wondering if you guys can provide any information with regard to this.

    Thanks.

  • We are a hibernate ceritified driver. YOu should use SQLServerDialect in the configuration see: http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html

    Let me know if there is anything specific you want to know.

    Thanks

    Mugunthan

  • I have a password protected database. How can I connect to it via JDBC? In what connection parameter I must send database password?

  • Hi,

    Before we can answer your question, we need to know which SQL Server Edition you are using. Could you please clarify?

    Thanks!

    Yesim [MSFT]

  • I've been trying to configure Tomcat 6.0 to use the SQL Server 2005 JDBC Driver to access SQL Server 2005 through a jndi provided DataSource.

    I am converting from programmatic creation of a Connection to using a DataSource to obtain a Connection.

    I'm using the following per web application WEB-INF\context.xml:

    <Context path="/eclipse" docBase="eclipse" debug="5" reloadable="true" crossContext="true">

       <Resource

           name="jdbc/orpsMirror"

           auth="Container"

           type="com.microsoft.sqlserver.jdbc.SQLServerDataSource"

           username="user"

           password="pass"

           driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

           url="jdbc:sqlserver://PN1236318.lanl.gov"

           validationQuery="select 1"

           maxActive="10"

           maxIdle="2"

       />

    </Context>

    and the following WEB-INF\web.xml fragment

    ...

       <resource-ref>

           <description>SQL Server</description>

           <res-ref-name>jdbc/orpsMirror</res-ref-name>

           <res-type>com.microsoft.sqlserver.jdbc.SQLServerDataSource</res-type>

           <res-auth>Container</res-auth>

       </resource-ref>

    ...

    When i execute something like the following code,

    ...

               ctx = new InitialContext();

               Object object;

               object = ctx.lookup("java:comp/env/jdbc");

    ...

    I get the following STDOUT log message

    javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

    Can you tell me how to configure Tomcat to allow servlets and JSP pages to access SQL Server? This has been somewhat frustrating.

    Thanks.

  • Hello. I'm developing my application in Sun Java Studio Creator and Sun AppServer 8.2. I have this application that uploads pdf files to the database. With SQLServer 2000 it works, but now I'm using the same application to upload files to SQLServer 2005 and it doesn't work. Is there any property or something else that I must set in the database in order to do this? Thanks in advance.

    Eric.

  • Sorry, I forgot to mention in my previous post that I'm using the latest JDBC driver (sqljdbc.jar v1.2.2727).

  • Hello Steve,

    The issue I believe you are hitting is your Context is not complete.  I've seen this done one of two ways:

    1.  Grab the environment first, and then grab the datasource

    // Grab the Environment first

    object = ctx.lookup("java:comp/env");

    // Now grab the DataSource

    DataSource ds = (DataSource)ctx.lookup("jdbc/orpsMirror");

    2. Grab the DataSource from the get go

    // Grab the DataSource with the full path from the Environment

    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/orpsMirror");

    I believe yours was failing because it was just looking for an element called "jdbc" which didn't exist.

    Hope that helps!

    Thanks,

    Adam [MSFT]

  • Correction to the first code segment I posted.  It should be:

    // Grab the Environment first

    Context envCtx = (Context)ctx.lookup("java:comp/env");

    // Now grab the DataSource

    DataSource ds = (DataSource)envCtx.lookup("jdbc/orpsMirror");

  • Hi,

      We are evaluating JDBC v1.2 and found out there is different with getBytes Method (SQLServerResultSet) call getBytes Method (SQLServerResultSet)

    this is output when I tried two drivers:

    using JDBC v1.1

    Timestamp from DB is: 2007-10-26 12:45:45.9

    byte array is:

    0 is -45

    1 is -103

    2 is 0

    3 is 0

    4 is -38

    5 is 82

    6 is -46

    7 is 0

    using JDBC v1.2

    Timestamp from DB is: 2007-10-26 12:44:42.04

    0 is 0

    1 is 0

    2 is -103

    3 is -45

    4 is 0

    5 is -46

    6 is 8

    7 is 4

    you can see first 4 elements values have been changed (with different order).  can someone provide more information about this? Thanks.

    --Tony

  • Hola actualice el sqljdbc 1.1 por la vesion 1.2 y al ejecutar cualquier consulta me da este error com.microsoft.sqlserver.jdbc.SQLServerException: La instrucción no devolvió un conjunto de resultados.

    Si me pudieran ayudar con esto... Gracias

  • Can you provide a sample that is failing?

    Thx

    ¿Puede usted proporcionar una muestra que falla?

  • I'm using Tomcat 5.5, J2SDK 1.4 and I want to access my db at MS SQL Server 2000. I'm getting error as

    "Following error/exception occured - java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.isAfterLast at"

    Also

    Following error/exception occured - java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.setFetchDirection at

    Any help???

  • Can you try the SQL 2005 JDBC Driver, this supports SQL 2000 server as well.

  • Hi Everyone,

    Does anyone know if it is possible through JDBC connection to have the loginto  SQL server automatically authenticate through AD(Active Directory - windows login, instead of entering a user name and password.) similar to single sign on.

    If possbile, how? Can anyone direct me to any documentations, etc?

    Thanks

Page 1 of 6 (79 items) 12345»