How to use escape character in password containing "="?

Discussão em 'StackOverflow' iniciado por Stack, Janeiro 4, 2021.

  1. Stack

    Stack Membro Participativo

    I am using microsoft sql database for my application which is deployed in jboss server. The database password contains like _i9wexp=tfd. This password works well in normal java class method and my local jboss dev studio datasource configuration

    My datasource config in local jboss standalone xml file

    <datasource jndi-name="java:jboss/datasources/Star-DS" pool-name="Star-DS" enabled="true" use-java-context="true">
    <connection-url>jdbc:sqlserver://server_name;DatabaseName=DB_NAME</connection-url>
    <driver>sqljdbc</driver>
    <security>
    <user-name>DB_USER_NAME</user-name>
    <password>_i9wexp=tfd</password>
    </security>
    </datasource>


    This works fine in local development connecting the server database. But when connecting from jboss server where is application is deployed and pointing the database connection from datasource.properties file below:

    connection-url=jdbc:sqlserver://server_name;DatabaseName=DB_NAME
    jndi-name=java:jboss/datasources/Star-DS
    driver-name=custom.mssql.default
    user=DB_USER_NAME
    password=_i9wexp=tfd


    When i deploy the application and open the application in browser i get the below error in log:

    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'DB_USER_NAME'. ClientConnectionId:62fc2ccd-9af6-4c3d-872c-eeb5376204bc
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
    at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)
    at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2926)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2243)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:42)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2229)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1716)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1327)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:992)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:828)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:296)
    ... 28 more

    09:40:38,508 WARN [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] (ServerService Thread Pool -- 60) HHH000342: Could not obtain connection to query metadata : javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/Star-DS
    09:40:38,512 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 60) MSC000001: Failed to start service jboss.persistenceunit."star.ear/starWeb.war#Star": org.jboss.msc.service.StartException in service jboss.persistenceunit."star.ear/starWeb.war#Star": javax.persistence.PersistenceException: [PersistenceUnit: Star] Unable to build EntityManagerFactory
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: Star] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
    ... 4 more
    Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
    at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:98)
    at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:170)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
    ... 9 more


    It successfully logged in sql server management studio also.

    How to access this password using escape characters in connecting the database through application?

    I have tried like way by using _i9wexp\=tfd but then also it is failed. Can anyone help me to solve this?

    Continue reading...

Compartilhe esta Página