mysql connectionpropertiestransform issue - help needed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samathak
    New Member
    • Oct 2008
    • 3

    mysql connectionpropertiestransform issue - help needed

    Hi,

    I have implemented com.mysql.jdbc. ConnectionPrope rtiesTransform class.

    In the jdbc connection url, I have added

    propertiesTrans form=com.mysql. jdbc.Connection PropertiesTrans formImpl

    attribute.

    I made jar of this implementation class file and i have placed this jar file inside webapps/ (application)/WEB-INF/lib. mysql-connector-java-5.0.4-bin.jar file is present inside \tomcat\common\ lib.


    I am getting following exception.

    Unable to create the properties transform instance 'com.mysql.jdbc .ConnectionProp ertiesTransform Impl' due to underlying exception java.lang.Class NotFoundExcepti on: com.mysql.jdbc. ConnectionPrope rtiesTransformI mpl


    If I place mysql-connector-java-5.0.4-bin.jar inside webapps/ (application)/WEB-INF/lib, its working fine.


    Any idea? Is it classpath/class loader issue?

    Thanks in advance
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by samathak
    Hi,

    I have implemented com.mysql.jdbc. ConnectionPrope rtiesTransform class.

    In the jdbc connection url, I have added

    propertiesTrans form=com.mysql. jdbc.Connection PropertiesTrans formImpl

    attribute.

    I made jar of this implementation class file and i have placed this jar file inside webapps/ (application)/WEB-INF/lib. mysql-connector-java-5.0.4-bin.jar file is present inside \tomcat\common\ lib.


    I am getting following exception.

    Unable to create the properties transform instance 'com.mysql.jdbc .ConnectionProp ertiesTransform Impl' due to underlying exception java.lang.Class NotFoundExcepti on: com.mysql.jdbc. ConnectionPrope rtiesTransformI mpl


    If I place mysql-connector-java-5.0.4-bin.jar inside webapps/ (application)/WEB-INF/lib, its working fine.


    Any idea? Is it classpath/class loader issue?

    Thanks in advance
    I think it is on the catalina.proper ties file, ( not sure )

    compare the values of common.loader and server.loader variables,
    what have you notice?

    Im not sure and i cannot confirm it(since i have uninstalled already my tomcat)

    but if you would like to try, have a back-up copy of catalina.proper ties

    add this at the end of server.loader --> ,${catalina.hom e}/common/lib/*.jar

    eg.

    server.loader=$ {catalina.home}/server/classes,${catal ina.home}/server/lib/*.jar,${catalin a.home}/common/lib/*.jar

    save, restart your Tomcat Server and observe,

    If you still cannot use the jar files inside the common/lib, replace the modified one with the unmodified(back-up) catalina.proper ties and stay on the WEB-INF/lib/ folder...... :)

    regards,
    sukatoa

    Comment

    • samathak
      New Member
      • Oct 2008
      • 3

      #3
      Originally posted by sukatoa
      I think it is on the catalina.proper ties file, ( not sure )

      compare the values of common.loader and server.loader variables,
      what have you notice?

      Im not sure and i cannot confirm it(since i have uninstalled already my tomcat)

      but if you would like to try, have a back-up copy of catalina.proper ties

      add this at the end of server.loader --> ,${catalina.hom e}/common/lib/*.jar

      eg.

      server.loader=$ {catalina.home}/server/classes,${catal ina.home}/server/lib/*.jar,${catalin a.home}/common/lib/*.jar

      save, restart your Tomcat Server and observe,

      If you still cannot use the jar files inside the common/lib, replace the modified one with the unmodified(back-up) catalina.proper ties and stay on the WEB-INF/lib/ folder...... :)

      regards,
      sukatoa

      Thank you very much..

      Let me explain my issue clearly..

      Actually, i need to login to database using application user login name and password. So after user has logged in , i need to get username and password and make the database connection using that..

      So i am using ConnectionPrope rtiesTransform and changing the database connection parameters.

      Right now, I have two jar files.

      1) mysql-connector
      2) my application custom jar.

      If i place my jar inside web-inf/lib , i am getting noclassdeffound exception.

      If i have placed my jar inside common/lib, since i am using spring framework outside web application, SecurityContext Holder /Authentication objects are coming null. So i am not able to retrieve user details..

      If i place mysql jar inside web-inf/lib, jndi connection to database is not establishing.

      I have played with catalina.proper ties. it does not solve my problem. After changing common-loader, i am not getting no class definition found error. But Securitycontext holder /Authentication objects are coming null..


      So please suggest me if there is any solution for this?

      Comment

      • sukatoa
        Contributor
        • Nov 2007
        • 539

        #4
        Originally posted by samathak
        Thank you very much..

        Let me explain my issue clearly..

        Actually, i need to login to database using application user login name and password. So after user has logged in , i need to get username and password and make the database connection using that..

        So i am using ConnectionPrope rtiesTransform and changing the database connection parameters.

        Right now, I have two jar files.

        1) mysql-connector
        2) my application custom jar.

        If i place my jar inside web-inf/lib , i am getting noclassdeffound exception.

        If i have placed my jar inside common/lib, since i am using spring framework outside web application, SecurityContext Holder /Authentication objects are coming null. So i am not able to retrieve user details..

        If i place mysql jar inside web-inf/lib, jndi connection to database is not establishing.

        I have played with catalina.proper ties. it does not solve my problem. After changing common-loader, i am not getting no class definition found error. But Securitycontext holder /Authentication objects are coming null..


        So please suggest me if there is any solution for this?
        ( i haven't use spring framework before )
        If i were to implement that, since the requirement ( username and password ) that will be used as a username/password for the database to connect,

        im going to create a bean that manage database connection( pooling using naming-factory-dbcp.jar )
        with a constructor parameter URL, DriverLocation, Schema, Username and Password,
        ( DriverManager needs URL(jdbc:mysql://localhost/ ), username and password)

        Following the setter/getter methods for the constructor parameter to be able to make it a dynamic connection switching....

        Every time the username and password changes, close the current connection instance and reconnect it using the new username and password together with all other parameters initialized.

        Having its own simplified executeQuery and executeUpdate methods and a closeConnection method that will invoked only after executeQuery method ( since the ResultSet returned must be used first in any desired transaction before closing a connection )

        And i will be used it as my Database connection manager.

        I also haven't use the com.mysql.jdbc. ConnectionPrope rtiesTransform class,
        but i think the goal is the same, please do correct me if im wrong,

        I believe that all programmer/developer defined jar files are recommended to put them in WEB/INF/lib directory, since the content of a WAR file that will be used for deployment are the ROOT/["USER"] directory under myapps folder.....

        i hope that it will make sense to you,

        regards,
        sukatoa

        Comment

        Working...