Mock tests, Interview questions, Tutorials and Tech news
 
 
Home > Programming / tutorials > Jboss 4 Server Configuration changes for SQL Server 2008

Jboss 4 Server Configuration changes for SQL Server 2008

Last week our Sql Server was upgraded to 2008 version. And the upgrade , I found following exception being thrown by when deploying our project.

com.microsoft.sqlserver.jdbc.SQLServerException: The server version is not supported. The target server must be SQL Server 2000 or later.

I upgraded the jdbc driver and replaced to sqljdbc.jar (version 2.0) and stored in lib folder of my project.
But the error was same as under—

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The server version is not supported. The target server must be SQL Server 2000 or later.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.DBComms.Prelogin(Unknown Source)
at com.microsoft.sqlserver.jdbc.DBComms.(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:171)
… 46 more
20:47:06,522 ERROR [STDERR] org.jboss.util.NestedSQLException: Could not create connection; – nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: The server version is not supported. The target server must be SQL Server 2000 or later.); – nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; – nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: The server version is not supported. The target server must be SQL Server 2000 or later.))
20:47:06,522 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)

After spending some time , I found that this issue will normally occur when you are using a older verison of JDBC driver to connect to sql server 2008. So make sure you are using sql server 2008 JDBC driver and you do not have sqlserver 2005 JDBC drivers in the classpath or in server/default/lib folder.

When you download the SQlserver 2008 JDBC driver from the Microsoft website, you will get two jar files: sqljdbc4.jar and sqljdbc.jar.
For JDK5 – use sqljdbc.jar
for JDK6 – use sqljdbc4.jar

When you JDK1.5 and trying to load sqljdbc4.jar, you might get the below exception.So use sqljdbc.jar[2008]
Exceptionjava.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

SQL Server 2008 Database Configuration on Jboss 4

To use JBoss 4.0 with SQL server, we first need to put the driver classes into the Project lib PATH. Copy the .jar file sqljdbc.jar to the /server/default/lib directory.
To use the SQL data source, mention driver-class in jndi file. by setting com.microsoft.sqlserver.jdbc.SQLServerDriver and jdbc:sqlserver://

MySQL Database Configuration on Jboss 4
To use JBoss 4.0 with MySQL, we first need to put the MySQL driver classes into the CLASSPATH. Copy the .jar file mysql-connector-java-3.0.9-stable-bin.jar to the /server/default/lib directory.
To use the MySQL data source, copy /docs/examples/jca/mysql-ds.xml to the /server/default/deploy directory. Modify the mysql-ds.xml configuration file by setting to com.mysql.jdbc.Driver and to jdbc:mysql:///, where is the MySQL host server and is the MySQL database.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • IndianPad
  • Reddit
  1. biboo
    March 20th, 2012 at 12:23 | #1

    Dear,
    but if i am using JDK 1.4 , why i cant connect to SQLSERVER 2008..???
    is there any solution for that?
    Regards

  2. March 8th, 2012 at 07:11 | #2

    Please check if driver is available in runtime environment. If using eclipse, add to build path

  3. Arun Kumar
    March 8th, 2012 at 01:09 | #3

    Jenifer Rajkumar :
    I am using microsoft sql server2008 i download Microsoft SQL Server JDBC Driver 3.0 and i set the class path as C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\sqljdbc4.jar; and my program is
    import java.sql.*;
    class Example
    {
    public static void main(String args[])
    {
    try
    {
    // Load the SQLServerDriver class, build the
    // connection string, and get a connection
    Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
    String connectionUrl = “jdbc:sqlserver:SQL1:sqlexpress;” +
    “database=MyDatabase;” +
    “user=sa;” +
    “password=Admin123″;
    Connection con = DriverManager.getConnection(connectionUrl);
    System.out.println(“Connected.”);
    // Create and execute an SQL statement that returns some data.
    String SQL = “SELECT * FROM MyTable”;
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(SQL);
    // Iterate through the data in the result set and display it.
    while (rs.next())
    {
    System.out.println(rs.getString(1) + ” ” + rs.getString(2));
    }
    }
    catch(Exception e)
    {
    System.out.println(e.getMessage());
    System.exit(0);
    }
    }
    }
    While compiling time no error but running time iam getting no suitable driver found for “jdbc:sqlserver:SQL1:sqlexpress;” +
    “database=MyDatabase;” +
    “user=sa;” +
    “password=Admin123″;
    please solve my issue.

  4. Jenifer Rajkumar
    March 8th, 2012 at 01:09 | #4

    I am using microsoft sql server2008 i download Microsoft SQL Server JDBC Driver 3.0 and i set the class path as C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\sqljdbc4.jar; and my program is
    import java.sql.*;

    class Example
    {
    public static void main(String args[])
    {
    try
    {
    // Load the SQLServerDriver class, build the
    // connection string, and get a connection
    Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
    String connectionUrl = “jdbc:sqlserver:SQL1:sqlexpress;” +
    “database=MyDatabase;” +
    “user=sa;” +
    “password=Admin123″;
    Connection con = DriverManager.getConnection(connectionUrl);
    System.out.println(“Connected.”);

    // Create and execute an SQL statement that returns some data.
    String SQL = “SELECT * FROM MyTable”;
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(SQL);

    // Iterate through the data in the result set and display it.
    while (rs.next())
    {
    System.out.println(rs.getString(1) + ” ” + rs.getString(2));
    }

    }
    catch(Exception e)
    {
    System.out.println(e.getMessage());
    System.exit(0);
    }
    }
    }

    While compiling time no error but running time iam getting no suitable driver found for “jdbc:sqlserver:SQL1:sqlexpress;” +
    “database=MyDatabase;” +
    “user=sa;” +
    “password=Admin123″;

    please solve my issue.

  5. September 18th, 2010 at 11:58 | #5

    Thanks for your kind words Deepti. We are glad it was helpful.

  6. Deepali Anand
    September 18th, 2010 at 11:05 | #6

    Thanks a lot. Recently, we migrated to sqlserver 2008 and your article proved to be very helpful

  1. April 5th, 2010 at 14:01 | #1
Get Adobe Flash playerPlugin by wpburn.com wordpress themes