JDBC/SQLServer errors

Hi all:
I have the folowing SELECT giving me some odd troubles from a Java application to a SQLServer 2000:
If i use a db manager (hsqldb) with the JdbcOdbc bridge driver, it works OK.
If i use a db manager (dBVisualizer) with the native driver, it works OK.
If i use it from within my application that is using the native driver, i get
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Incorrect syntax near the keyword 'AS'.
Wath is going on?
SELECT Tarefa.Tarefa_K, Tarefa.Processo_K, Tarefa.DataAbertura, Tarefa.AssuntoTarefa, DocumentoItem.Referencia, DocumentoHeader.NomeFriendly, [NomeLogin]+' ('+[NomeUtente]+')' AS Responsavel, Utente.Utente_K, (SELECT Max(Versao) FROM DocumentoItem DI WHERE DI.DocumentoHeader_K = DocumentoHeader.DocumentoHeader_K) AS Versao, DocumentoHeader.DocumentoHeader_K FROM ((Utente INNER JOIN Tarefa ON Utente.Utente_K = Tarefa.UtenteAtribuido_K) INNER JOIN DocumentoHeader ON Tarefa.Tarefa_K = DocumentoHeader.Origem_K) INNER JOIN DocumentoItem ON DocumentoHeader.DocumentoHeader_K = DocumentoItem.DocumentoHeader_K WHERE ((((SELECT Max(Versao) FROM DocumentoItem DI WHERE DI.DocumentoHeader_K = DocumentoHeader.DocumentoHeader_K))=[DocumentoItem].[Versao]) AND ((DocumentoHeader.DocumentoContexto)='TAREFA') AND (Tarefa.Processo_K='K00005'))

You posted what you think the code is doing.
That isn't a good idea.
Print it out.
You will find that your problem is a missing space, comma, etc or some other type of syntax error.

Similar Messages

  • JDBC SQLServer: Error when loosing connection

    Hi all,
    I have this problem: I�m using microsoft jdbc driver for sqlserver 4 to connect to my sqlserver database. The connection is working just fine, but I want to create a method to reconnect to the database if the connection is lost (for example, if the SQLServer machine is rebooted).
    I test to see whether if the connection is closed. If it�s closed, I set the connection to null and try to connect again, but it gives me this error:
    [Microsoft][SQLServer JDBC Driver][SQLServer]Cannot open database requested in login 'XXXX'. Login fails.
    The login and password are the same. Nothing is different from the first routine that connects to the database.
    If I shutdown the application and start again, it works. So, my problem is with the reconnect routine, but it just calls the first connect routine.
    What could be the problem? any hints?
    Tks a lot
    Rodrigo

    Ok
    Here is part of my code:
    First of all, I call this code in the constructor of the object:
    con = getConnection();
    Here is the getConnection code:
         private Connection getConnection()
              LogFile.logInfo("MMSSender","getConnection()","Creating connection...");
              try
                   con = DataBaseManager.getConnection();          
              catch (Exception e)
                   LogFile.logError("MMSSender","getConnection()",e.getMessage());
              LogFile.logInfo("MMSSender","getConnection()","Connection created.");
              return con;
    here is the reConnect() code
         public void reConnect()
              try
                        DataBaseManager.releaseConnection(con);
                        LogFile.logInfo("MMSSender","reConnect()","Reabrindo conex�o com o banco de dados ...");
                        con = getConnection();
                        LogFile.logInfo("MMSSender","reConnect()","Conex�o reaberta com sucesso");
              catch (Exception e)
                   LogFile.logError("MMSSender","reConnect()",e.getMessage());
    //DATABASEMANAGER class
    public static Connection getConnection() throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, ConstanteException{
         Connection conn     = null;
         String login = null;
         String password = null;
         String connect = null;
         String driver = null;
         login      = Constantes.getConstante("usr");
         password = Constantes.getConstante("pass");
         connect      = Constantes.getConstante("connStr");
         driver = Constantes.getConstante("driver");
         cls = Class.forName(driver);
         d = (Driver) cls.newInstance();
         DriverManager.registerDriver(d);
         conn = DriverManager.getConnection(connect, login, password);
         return conn;
    public static void releaseConnection(Connection conn) {
         try {
              conn.close();
              conn = null;
         catch (Exception e){
              System.out.println("Erro ao liberar a conex�o com a base de dados: "+e);
    Tks again
    Rodrigo

  • [BEA][SQLServer JDBC Driver]Error

    hi
    i am veeresh.s, in 1 of our user this below error has came,i am a fresher, i don't know how to resolve it, please any body help me in resolving this error
    user gets the following error message when the user try to create a connection pool to connect user weblogic server to oracle server.
    Error:
    [BEA][SQLServer JDBC Driver]Error establishing socket to host and port: dt2888-swaminat:1433. Reason: Connection refused: connect
    The Network Adapter could not establish the connection
    user is unable to telnet to that machine. user suspect that it to be some driver issue.
    So what may be the problem,
    please look into the problem and Kindly help me in resolving this issue.

    This appears to be a duplicate thread. I posted a reply in the other forum
    Re: [BEA][SQLServer JDBC Driver]Error
    Justin

  • Error in adapterlog: JDBC connection error

    Hi Experts,
    I am getting this error during database connection to the database URL 'jdbc:sqlserver:// <servername>:1433;database=HRBD' using the JDBC driver 'com.microsoft.sqlserver.jdbc.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:sqlserver://<servername>:1433;database=HRBD': com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host  has failed. java.net.ConnectException: Connection timed out'
    I am able to connect this server from Microsoft SQL Server2005(Which does not require the port number) but when I am trying to connect from PI JDBC sender adapter ,I am getting this error.
    It is a SQL Server.JDBC driver seems ok(com.microsoft.sqlserver.jdbc.SQLServerDriver) because I connected the Staging database server from PI but unable to connect to this production database.
    After starting the channel ,after 5-7 minutes I am getting this error.
    Need your help on urgent basis!!
    regards
    Anupam

    Anupam Ghosh wrote:
    Hi Navin,
    >
    > I made a telnet test from putty giving the server name and port number and it showed me the "connection timed out".
    > But I made telnet test to other database which resulted in successful connection.
    > So is it a firewall issue with that particular databse?
    > In that case only network team of that databse can handle this issue?
    >
    > Thanks,
    > Jaydeep
    Few things that mght help u 
    1. Check the port no for the DB that is getting timed out. .check
    2. Disable the firewall. and check
    3. Consult the N/w and the DB team.. .telling clearly the issue
    Good Luck
    XA

  • Error in JDBC Adapter-"Error establishing socket"

    Hi,
    I am getting an error in the seander JDBC adapter. PFB the error:
    Error during database connection to the database URL 'jdbc:microsoft:sqlserver://Server Name;DatabaseName=DB Name;SelectMethod=cursor' using the JDBC driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:microsoft:sqlserver://Server Name;DatabaseName=DB Name;SelectMethod=cursor': SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.'
    Can any one hlep me to resolve the error.
    Thanks,
    RK

    Hi,
    Also check whether you have given database connection parameters in the following format:
    JDBC Driver:
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    Connection:   jdbc:microsoft:sqlserver://<HOSTNAME>:1433;DatabaseName=<xxxx>;SelectMethod=cursor
    I think the deployment is done, because you have not got "SAPClassNotFoundException" error.(If the deployment is not done, the driver file cant be located so this will be thrown...)
    Thanks & Regards,
    Senthil.

  • XI: RFC to JDBC scenario - handle JDBC Adapters Errors

    In scenario could happened to ERP side try to insert an already saved record in receiver side SQL Server. when this happens XI returns a message structure like :
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
      <!--  Call Adapter
      -->
      <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Category>XIAdapterFramework</SAP:Category>
      <SAP:Code area="MESSAGE">GENERAL</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'dbo.ZZTest01' (structure 'Statement_aux'): java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Violation of PRIMARY KEY constraint 'PK_ZZTest01'. Cannot insert duplicate key in object 'ZZTest01'.</SAP:AdditionalText>
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack />
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    But i need to read this error message and map to RFC response structure, how can i do that?

    Hi Karoline,
         Well, i create a BPM process and put a Block Step with Exception Lane, so in normal lane a create a Send Step with the JDBC message, and when an error occurs the process goes to the Exception Lane and there a create a Transform Step with other mapping for de response message for the beginner step, something like:
    1º) Receive Step: Sender system with open bridge;
    2º) Transform Step: mapping de Sender message request to JDBC request message;
    3º) Block Step:
         3.1) Normal Lane: Send Step for JDBC Receiver System;
         3.2) Exception Lane: Transform Step with a message mapping with a constant error message;
    4º) Send Step: Sender System with closes bridge;
    I couldn´t pick up the correct error message from jdbc driver, but in this model my process doesn´t stop with a JDBC error.
    If you have an eMail address i can send to you my model.

  • How to handle the jdbc receiver error

    hi,expert:
      I have a synchornous scenario:SAP/ECC(Proxy) to JDBC(SQLServer),ECC Send the message and insert data into the  database,when insert sucessfully the receiver returns the count of the sucessfull inserted  record . Not use store    procedure.
    I have a problem: When insert into the table occurs errors,like insert Duplicated record,how can i capture this exception and return  to the ECC? And if it is possible to solve this problem by using fault message?
         wait for reply ,thanks!

    Have you identified why duplicate record error coming?? you dont want to insert duplicate records in DB?? then in this case you contraol sending data in Proxy it self,
    If you want response (error message or success status from Data base you can design/develop easily, JDBC recv will support syn communication.
    even you can go for fault message type to handle this error,
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/dd/b7623c6369f454e10000000a114084/content.htm
    Regards,
    Raj

  • Com.microsoft.jdbc.sqlserver.SQLServerDriver

    Hi all,
    i'm trying jsp and ms sql 200 connection...
    here is the code i use:
    <html>
    <head>
    <%@ page
         import = "java.io.*"
         import = "java.lang.*"
         import = "java.sql.*"
    %>
    <title>ma quanto so bravo</title>
    </head>
    <body>
    <%
         String     place;
         Connection dbconn;
         ResultSet results;
         PreparedStatement sql;
         //SQL server 2000
         String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String sourceURL = "jdbc:microsoft:sqlserver://192.168.0.14:31000;databasename=prova";
    String username = "sa";
    String password = "riccio72";
         try
              //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
              try
                   int     latitude,longitude,easting,northing;
                   boolean     doneheading = false;
                   //dbconn = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=E:\\ATTENTATO\\Pubblicazione\\vecchia pubblicazione\\jsp\\collegamento a db\\prova.mdb");
                   dbconn = DriverManager.getConnection(sourceURL, username, password);
                   place = request.getParameter("place");
                   sql = dbconn.prepareStatement("SELECT * FROM info WHERE name = '" + place + "'");
                   results = sql.executeQuery();
                   while(results.next())
                        if(! doneheading)
                             doneheading = true;
    latitude = results.getInt("latitude");
    longitude = results.getInt("longitude");
    easting = results.getInt("easting");
    northing = results.getInt("northing");
                        out.println("<table border=2>");
                        out.println("<tr><td>" + latitude);
                        out.println("<td>" + longitude);
                        out.println("<td>" + easting);
                        out.println("<td>" + northing);
                        out.println("</tr></table> <br>");
                   //if(doneheading)
                   results.close();
                   dbconn.close();
                   if(! doneheading)
                        out.println("No matches for " + place);
              catch (SQLException s)
                   out.println("SQL Error<br>");
                   out.print(s);
         catch (ClassNotFoundException err)
              out.println("Class loading error");
    %>
    </body>
    </html>
    Place is a variable from anothe page
    i have this error Class loading error
    How can i set this problem'?
    i have installed jrun4 sql 2000 and jdbc driver from microsoft
    i have read that i have to set the classpath and register the driver but i need particular description on how to do it
    thx

    Hi all,
    I am facing some serious problem regarding the same,
    I have done the SQL server connectivity successfully.
    But when I create the executable file of the class file, it gives me error.
    I am sending the code,
    *************** DBInterface.java ***********************
    import java.*;
    import java.sql.*;
    import javax.swing.*;
    import java.util.*;
    import com.microsoft.jdbc.sqlserver.SQLServerDriver;
    public class DbInterface
      //Connection Parameters
        protected static java.sql.Connection  con = null;
        protected final String url = "jdbc:microsoft:sqlserver";
        protected final String serverName= "localhost";
        protected final String portNumber = "1433";
        protected final String databaseName= "DBCONNECT";
        protected final String userName = "sa";
        protected final String password = "PASSWORD";
        // constructor
        protected DbInterface()
         try
            con= this.getConnection();     
            if(con!=null)
         System.out.println("Successfully connected!");
           else
          System.out.println("Error: No active Connection");
       catch(Exception e)
                  e.printStackTrace();
    // returns url string
    protected String getConnectionUrl()
      {             return url+"://"+serverName+":"+portNumber+";databaseName="+databaseName;
       // function which connects to database
      protected java.sql.Connection getConnection()
           try{
                    Driver d = (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                     con = DriverManager.getConnection(getConnectionUrl(),userName,password);
                    if(con!=null) System.out.println("Connection Successful!");
              }catch(Exception e){
               JOptionPane.showMessageDialog(new JFrame(), e.getMessage(), "Error Message", JOptionPane.ERROR_MESSAGE);
                   e.printStackTrace();
                   System.out.println("Error Trace in getConnection() : " + e.getMessage());
              return con;
    protected void closeConnection()
              try{
                   if(con!=null)
                        con.close();
                   con=null;
                   System.out.println("Close Connection");             
              catch(Exception e)
                   e.printStackTrace();
    ********* TestConnection.java************************
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class  TestConnection
       public static void main(String[] args)
               DbInterface getlive = new DbInterface();
               if(DbInterface.con != null)
                 JOptionPane.showMessageDialog(new JFrame(), "Successfully Connected!", "Error Message", JOptionPane.ERROR_MESSAGE);
                  getlive.closeConnection();
              else
         JOptionPane.showMessageDialog(new JFrame(), "Not Connected!", "Error Message", JOptionPane.ERROR_MESSAGE);
               System.exit(0);
    }Both this files are compiled well.
    Now when I create an excutable file for this, it unable to connect sql server.
    (Note : I have created executable file using JSmooth & also tried with manually jar executable.)
    Can somebody focus on this issues?
    Thanx & Regards,
    Mahesh

  • ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver

    Dear all
    i am using MSSQL2000 Driver for jdbc, i have set CLASSPATH to the driver install directory, compile passed, but when i run class, a ClassNotFoundException error occur:
    java.lang.ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver
    i am using jdk1.2.2
    hope to get your tips!
    Luke

    Dear all
    i am using MSSQL2000 Driver for jdbc, i have set
    t CLASSPATH to the driver install directory, compile
    passed, but when i run class, a ClassNotFoundException
    error occur:
    java.lang.ClassNotFoundException:com.microsoft.jdbc.sql
    erver.SQLServerDriver
    i am using jdk1.2.2
    hope to get your tips!
    Lukehi Luke,
    I dont know if it is in someway related to ur jdk version..
    but your error message seems to be
    java.lang.ClassNotFoundException:com.microsoft.jdbc.sql
    erver.SQLServerDriver
    Plz consider this possibility if
    u might have given the classname wrong as
    com.microsoft.jdbc.sqlerver.SQLServerDriver
    which throws the exception as shown in the error message!!
    try giving the correct classname as com.microsoft.jdbc.sqlserver.SQLServerDriver
    which may solve your problem..
    cheers,
    -Jer

  • JDBC Adapter Error to conect to SQL Server 2005

    Hi all.
    I´m trying to conect to a SQL Server 2005 database, but facing this error:
    UnsupportedClassVersionError: (com/microsoft/sqlserver/jdbc/SQLServerDriver) bad major version at offset=6'
    The parameters are:
    JDBC Driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
    Connection: jdbc:sqlserver://
    How can I resolve this issue?
    Thanks.

    The jdbc driver seems to be incompatible. Use the compatible version from [http://www.microsoft.com/downloads/details.aspx?familyid=99B21B65-E98F-4A61-B811-19912601FDC9&displaylang=en|http://www.microsoft.com/downloads/details.aspx?familyid=99B21B65-E98F-4A61-B811-19912601FDC9&displaylang=en]

  • SAPClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

    Hi...Experts....
    Requirement:
    From our PI 7.1 System we have to connect to MS-SQL Server 2000 using JDBC.
    Execution :
    We have downloaded
    Microsoft SQL Server JDBC Driver 3.0 ...and...Microsoft SQL Server JDBC Driver 2.0 ( We mean we tried both drivers)and deployed using JSPM in PI system
    To deploy this ..We used & reviewed the following notes
    Note 0000831162 - FAQ: XI 3.0 / PI 7.0 / PI 7.1 JDBC Adapter
    Note 0001138877 - PI 7.1 : How to Deploy External Drivers JDBC/JMS Adapters
    Note 0000850116 - XI 3.0 / PI 7.0 JDBC Adapter: Type 2 JDBC Driver Deployment
    Note 0001123333 - Redeploying same component with JSPM
    Issue Observation Path :
    in JSPM ...The deployment is successfull
    But in
    >Runtime Workbench NetWeaver Administrator
    >>Component Monitoring
    >>>Compnenet with status ..ALL...[DISPLAY]
    >>>Adapter Engine
    >>>>Communication Channel 
    We continuioulsy see the following error
    ERROR :
    Error during database connection to the database URL 'jdbc:microsoft:sqlserver://101.197.135.118:1433;databaseName=LWV' using the JDBC driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:microsoft:sqlserver://101.197.135.118:1433;databaseName=LWV': SAPClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver'
    ERROR:
    In this Juncture...We have 2 queires.
    01. How to make the Deployed JDBC Driver avaialbiliy in the system.
    02. Any other alternate way to make sure our self deployed JDBC well installed in system and can be used from PI Console.
    Regards
    PR

    Imran ...Thank U Very much...
    We could able to move forward.
    as in Java Instance :
    In directory : DRIVE:\usr\sap\<SID>\DVEBMGS<NN>j2ee\cluster
    We can see : instance.properties
    We copied the  3 files  (01) sqljdbc4.jar, (02) msutil.jar, (03) msbase.jar  into a directory like
    DRIVE:\usr\sap\<SID>\DVEBMGS<NN>j2ee\cluster\bin\ext\com.sap.aii.adapter.lib\lib\
    In the "configtool"  we configured these 3 jar files in class path like :
    DRIVE:\usr\sap\<SID>\DVEBMGS<NN>j2ee\cluster\bin\ext\com.sap.aii.adapter.lib\lib\sqljdbc4.jar;
    DRIVE:\usr\sap\<SID>\DVEBMGS<NN>j2ee\cluster\bin\ext\com.sap.aii.adapter.lib\lib\msutil.jar;
    DRIVE:\usr\sap\<SID>\DVEBMGS<NN>j2ee\cluster\bin\ext\com.sap.aii.adapter.lib\lib\msbase.jar
    and restarted the Instance, which in turn updated the instance.properties
    and we could see the errors stopped coming in the "XI Runtime WorkBench - Component Monitoring"
    We could see as
    >>>Processing started
    >>>Processing finished successfully
    >>>Polling interval started. Length: 60.0 seconds
    So we understood, the connection could db server and we conformed we moved a head on the issue
    Summarized Notes List :
    Note 0000831162 - FAQ: XI 3.0 / PI 7.0 / PI 7.1 JDBC Adapter
    Note 0001138877 - PI 7.1 : How to Deploy External Drivers JDBC/JMS Adapters
    Note 0000850116 - XI 3.0 / PI 7.0 JDBC Adapter: Type 2 JDBC Driver Deployment
    Note 0001123333 - Redeploying same component with JSPM
    Note 0000639702 - JDBC Driver for Microsoft SQL Server
    Rgds
    PR

  • Can anyone Solve the JDBC adapter error :

    Hi experts!!!
                 Whn I run File(FTP) to MSSQL Server ( JDBC), I m getting an error
    <b>
    Receiver Adapter v1027 for Party '', Service 'BS_JDBC_R2':
    Configured at 12:16:42 2007-01-05
    Last message processing started 12:17:09 2007-01-05, Error: Accessing database connection 'jdbc:Microsoft:sqlserver://sapep:1433;databaseName=tescra' failed: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    Addtional information: JDBC driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver' loaded successfully, additional driver information:
    Available JDBC drivers:
        com.microsoft.jdbc.sqlserver.SQLServerDriver, 2.2 JDBC compliant</b>
    Pls help me.... I have to clear it up.....
    <b>If anyone solves this they gud gud points from me...trust me..really!!!!!</b>
    Thanks in advance....

    hi,
    have a look at this:
    http://support.microsoft.com/kb/313178
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • JDBC SqlServer connection problem

    Hi,
    I'm trying to connect to a local Sql Server database. I started out connecting to a database on another computer on the network by using the following code:
    //Set up connection to database
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String serverName = "10.42.8.102";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String databaseName = "traffic";
    String url = "jdbc:microsoft:sqlserver://" + mydatabase +";databaseName="+databaseName+";";
    String username = "sa";
    String password = "foobar";
    // Load the JDBC driver
    Class.forName(driverName);
    // Create a connection to the database
    connection = DriverManager.getConnection(url, username, password);
    This worked fine. However, when I started trying to connect to a database on my own computer, I started having problems. The database I'm trying to connect to is listed under the node "TERRAIN\BEATTHETRAFFIC" in SqlServer's Enterprise Manager. The database name is still traffic, and the user name and password are unchanged. My new code is as follows:
    String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String serverName = "localhost/TERRAIN/BEATTHETRAFFIC";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String databaseName = "traffic";
    String url = "jdbc:microsoft:sqlserver://" + mydatabase +";databaseName="+databaseName+";";
    String username = "sa";
    String password = "foobar";
    // Load the JDBC driver
    Class.forName(driverName);
    // Create a connection to the database
    connection = DriverManager.getConnection(url, username, password);
    I have also tried the following as the serverName:
    "TERRAIN\\BEATTHETRAFFIC"
    "localhost/TERRAIN\\BEATTHETRAFFIC"
    "127.0.0.1/TERRAIN\\BEATTHETRAFFIC"
    I have tried the above with / instead of \\ as well.
    With these, I get the error:
    [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    I have also tried doing
    "localhost:TERRAIN\\BEATTHETRAFFIC" and
    "localhost:TERRAIN/BEATTHETRAFFIC" and used 127.0.0.1 instead of "localhost" as well.
    but with these I get
    [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
    I'm honestly at my wits' end here. I haven't really tried to connect to a Sql Server database before, and haven't done much work with connecting to databases in general, so maybe I'm making some glaringly obvious mistake, so if anyone could point it out, I'd be very grateful.

    For the value of serverName, you need to use an Internet-style host name, or an IP-address, not a Windows resource name.
    Examples of an internet-style host name are:
    this_host
    this_host.my_company.com
    Names with slashes in them are not Internet-style.
    The requirement is that name be something that your operating system can convert to an IP address. At least on newer versions of Windows (and most versions of Unix/Linux) you can find out the host name, with the "hostname" command. On windows:
    Click the Start button.
    Click the Run... link
    Enter "cmd" into the command line and click OK ( a new command window will open)
    In the new command window, enter "hostname" and hit enter. The system will give you the host name you need to use (upper/lower case does not matter).
    To confirm that the name ought to work, in that still-open command window, enter "ping [whatever the host name is]". You should get about 10 lines back that includes 4 lines that begin with "Reply from [your IP address] ..."

  • Websphere Application Server an JDBC Driver errors

    We're currently testing the BEA JDBC/SQLServer driver on IBMs websphere Application server and have encountered a couple of problems, which are described below. Has anyone encountered these before, and are there solutions to fixing them.
    Problem 1. All JDBC queries through the drivers cause the following error message to be displayed on the application server console:-
    #Weblogic -- Applet Access
    ......Illegal System.exit() attempted
    2. We get an intermittent problem where a JDBC query causes the following exception:-
    12-Aug-2002 14:08 | [Servlet.Engine.Transports:8] | ERROR | |
    User Action: displayParams
    Error Message: JVMLK003: current thread not owner
    Exception Message: JVMLK003: current thread not owner
    java.lang.IllegalMonitorStateException: JVMLK003: current thread not owner
    at java.lang.Object.notify(Native Method)
    at
    weblogic.jdbcbase.mssqlserver4.TdsConnection.registerPipeline(TdsConnection.
    java(Compiled Code))The only solution to the 2nd problem, that I've found, is to restart the application server.
    Are these drivers compatible with IBMs Websphere Application Server v4.0 Advanced?
    Any help would be appreciated.
    Regards
    Andrew

    please see my answers inline... I recommend you try the JDBC driver from
    Microsoft.
    sree
    "Andrew Danieli" <[email protected]> wrote in message
    news:[email protected]..
    We're currently testing the BEA JDBC/SQLServer driver on IBMs websphereApplication server and have encountered a couple of problems, which are
    described below. Has anyone encountered these before, and are there
    solutions to fixing them.
    >
    Problem 1. All JDBC queries through the drivers cause the following errormessage to be displayed on the application server console:-
    >
    #Weblogic -- Applet Access
    ......Illegal System.exit() attemptedThis is happening in your application code not in the driver.
    >
    2. We get an intermittent problem where a JDBC query causes the followingexception:-
    >
    12-Aug-2002 14:08 | [Servlet.Engine.Transports:8] | ERROR | |
    User Action: displayParams
    Error Message: JVMLK003: current thread not owner
    Exception Message: JVMLK003: current thread not owner
    java.lang.IllegalMonitorStateException: JVMLK003: current thread not
    owner
    at java.lang.Object.notify(Native Method)
    atweblogic.jdbcbase.mssqlserver4.TdsConnection.registerPipeline(TdsConnection.
    java(Compiled Code))This sounds more like an IBM JVM issue.
    >
    The only solution to the 2nd problem, that I've found, is to restart theapplication server.
    >
    Are these drivers compatible with IBMs Websphere Application Server v4.0Advanced?
    They are JDBC1.0 compliant drivers and should work with any jdbc app.
    >
    Any help would be appreciated.
    Regards
    Andrew

  • Java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDri

    I am sorry in advance, because I know this topic has been posted many times, but I think after reading all the solutions and trying everything I may have messed myself up worse.
    I am trying to run this simple script to connect to my SQL database
    import java.sql.*;
      * Microsoft SQL Server JDBC test program
    public class Test {
      public Test() throws Exception {
        // Get connection
        DriverManager.registerDriver(new
        com.microsoft.jdbc.sqlserver.SQLServerDriver());
        Connection connection = DriverManager.getConnection(
        "jdbc:microsoft:sqlserver://<Host>:1433","<UID>","<PWD>");
        if (connection != null) {
         System.out.println();
          System.out.println("Successfully connected");
          System.out.println();
          // Meta data
          DatabaseMetaData meta = connection.getMetaData();
          System.out.println("\nDriver Information");
          System.out.println("Driver Name: "
           + meta.getDriverName());
          System.out.println("Driver Version: "
           + meta.getDriverVersion());
          System.out.println("\nDatabase Information ");
          System.out.println("Database Name: "
           + meta.getDatabaseProductName());
          System.out.println("Database Version: "+
          meta.getDatabaseProductVersion());
    } // Test
    public static void main (String args[]) throws Exception {
      Test test = new Test();
    }I have set "PATH" in environmental variables (running windows)to be
    C:\Program Files\Java\jdk1.6.0_04\bin;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jarSo when i Compile i get the error..
    C:\SQLcode>javac Test.java
    Test.java:9: package com.microsoft.jdbc.sqlserver does not exist
        com.microsoft.jdbc.sqlserver.SQLServerDriver());Additionally, when i run
    java com.microsoft.jdbc.sqlserver.SQLServerDriver
    I get
    Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/jdbc/sq
    lserver/SQLServerDriver
    Caused by: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLSer
    verDriverFinally, I have even ran javac -classpath "C:\Program Files\Microsoft SQL Server 2000 Driver f
    or JDBC\lib\;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msba
    se.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserve
    r.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar"
    Test.java Which will compile correctly! However when I run the same command just with the java command as opposed to the javac command, I get
    Exception in thread "main" java.lang.NoClassDefFoundError: Test/java
    Caused by: java.lang.ClassNotFoundException: Test.java
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source) While there is a Class file in the directory.. Sorry for such a long post but I have been trying to fix this for two days now.. thank you

    Ok well i tried a number of combinations..
    My code lets say is in a folder C:\SQLCode which was successfully compiled using the command above..
    I tried doing what you suggested and got
    C:\SQLcode>java -cp .;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC
    \lib\;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;
    C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C
    :\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar Test
    Exception in thread "main" java.lang.NoClassDefFoundError: Files\Microsoft
    Caused by: java.lang.ClassNotFoundException: Files\Microsoft
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)I also tried without the direct links to the .jar files (just put the DIR) and got the same result.Any other suggestions?

Maybe you are looking for

  • Production Order backflush creating Negative in Storage Type

    Hi All, We have setup storage types into which stock is replenished based on Min/Max. These storage types have been setup in a control cycle and supply area to backflush upon confirmation of the production order. I know this is user error, but when d

  • Problem with java XMLLoader

    I have used the XMLLoader utility in Steves book and it appears to work, when I run this from the command line I get the message: Connecting as xmluser at jdbc:oracle:thin:@pan:1521:reqpro 00001: Inserted. Processed 1 Documents however the tables in

  • Firewire 400 doesn't appear

    I'm using a Macbook 13" white running 10.5.8. Trying to connect a Glyph external hard drive using a firewire 800 to 400 cable to Macbook. Cable and Glyph work on an older mac but my Macbook doesn't see it. Any ideas?

  • Defaulting Segment Values at Invoice Distribution using personalization

    Hi, My requirement is to default segment3 and segment4 values at invoice distribution gl account for manual invoices. Defualt values will be captured at DFF in user creation form. Can any one suggest how to proceed or whether this is possible through

  • FMS server v3.5 filterd port 1935 via Prolexic Services

    Hello all, we recently obtained the services of Prolexic.com for antiDdos protection. However when streaming rtmpe via port 1935 the movies buffer quite a bit.. I was wondering if there is anything i should be telling the folks at Prolexic to do to m