log4j problem in database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    log4j problem in database.

    Hi,
    I am using log4j to create log message. I want to write the log message to database. So i configured the log4j.propertie s files like this...


    Code:
    # Database Configuration
    log4j.appender.dbase          =org.apache.log4j.jdbc.JDBCAppender
    log4j.appender.dbase.layout   =org.apache.log4j.PatternLayout
    log4j.appender.dbase.driver   =com.microsoft.sqlserver.jdbc.SQLServerDriver
    log4j.appender.dbase.URL      =jdbc:sqlserver://win2003:1433/MyApp
    log4j.appender.dbase.user     =user
    log4j.appender.dbase.password =password
    #log4j.appender.dbase.sql     =INSERT INTO JDBCTEST VALUES ('%d - %c - %p - %m')
    But i have the following errors. Where im going to wrong...

    Code:
    log4j:ERROR Failed to excute sql
    com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433/Pricing is not valid.
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    	at java.sql.DriverManager.getConnection(DriverManager.java:512)
    	at java.sql.DriverManager.getConnection(DriverManager.java:171)
    	at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
    	at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
    	at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
    	at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
    	at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
    	at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
    	at org.apache.log4j.Category.callAppenders(Category.java:206)
    	at org.apache.log4j.Category.forcedLog(Category.java:391)
    	at org.apache.log4j.Category.log(Category.java:856)
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by rsrinivasan
    Hi,
    I am using log4j to create log message. I want to write the log message to database. So i configured the log4j.propertie s files like this...


    Code:
    # Database Configuration
    log4j.appender.dbase          =org.apache.log4j.jdbc.JDBCAppender
    log4j.appender.dbase.layout   =org.apache.log4j.PatternLayout
    log4j.appender.dbase.driver   =com.microsoft.sqlserver.jdbc.SQLServerDriver
    log4j.appender.dbase.URL      =jdbc:sqlserver://win2003:1433/MyApp
    log4j.appender.dbase.user     =user
    log4j.appender.dbase.password =password
    #log4j.appender.dbase.sql     =INSERT INTO JDBCTEST VALUES ('%d - %c - %p - %m')
    But i have the following errors. Where im going to wrong...

    Code:
    log4j:ERROR Failed to excute sql
    com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433/Pricing is not valid.
    	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    	at java.sql.DriverManager.getConnection(DriverManager.java:512)
    	at java.sql.DriverManager.getConnection(DriverManager.java:171)
    	at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
    	at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
    	at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
    	at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
    	at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
    	at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
    	at org.apache.log4j.Category.callAppenders(Category.java:206)
    	at org.apache.log4j.Category.forcedLog(Category.java:391)
    	at org.apache.log4j.Category.log(Category.java:856)
    I'm not sure what your URL format should be but as you can see from the exception it's trying to use 1433/Pricing as the port. Perhaps you should have separated the 1433 and the Procing with a colon(:)?

    Comment

    • rsrinivasan
      New Member
      • Mar 2007
      • 221

      #3
      Originally posted by r035198x
      I'm not sure what your URL format should be but as you can see from the exception it's trying to use 1433/Pricing as the port. Perhaps you should have separated the 1433 and the Procing with a colon(:)?
      I separated my port number and and MyApp(Pricing) by colon(:). Still i have the same error like this..

      Code:
      com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433:Pricing is not valid.
      	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
      	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
      	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
      	at java.sql.DriverManager.getConnection(DriverManager.java:512)
      	at java.sql.DriverManager.getConnection(DriverManager.java:171)
      	at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
      	at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
      	at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
      	at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
      	at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
      In this,

      Code:
       win2001 --> is my database server name
          1433      --> is the my database access port number
          Pricing   --> is my Web application
      What to do?

      Thanks,

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by rsrinivasan
        I separated my port number and and MyApp(Pricing) by colon(:). Still i have the same error like this..

        Code:
        com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433:Pricing is not valid.
        	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
        	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
        	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
        	at java.sql.DriverManager.getConnection(DriverManager.java:512)
        	at java.sql.DriverManager.getConnection(DriverManager.java:171)
        	at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:212)
        	at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:175)
        	at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
        	at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
        	at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
        In this,

        Code:
         win2001 --> is my database server name
            1433      --> is the my database access port number
            Pricing   --> is my Web application
        What to do?

        Thanks,
        What if you don't put the application name at the end of the port?

        P.S I'm clutching at straws here. The correct thing would be to read about what the URL format should be like.

        Comment

        • rsrinivasan
          New Member
          • Mar 2007
          • 221

          #5
          Originally posted by r035198x
          What if you don't put the application name at the end of the port?

          P.S I'm clutching at straws here. The correct thing would be to read about what the URL format should be like.
          URL is ==> http://localhost:8201/Pricing

          I have the Error(Exception ), when i deploy my application.

          Thanks,

          Comment

          Working...