开发者

How can you connect to a password protected MS Access Database from a Spring JdbcTemplate?

I need to connect to a password protected MS Access 2003 DB using the JDBC-ODBC bridge. I can't find out how to specify t开发者_Go百科he password in the connect string, or even if that is the correct method of connecting.

It would probably be relevant to mention that this is a Spring App which is accessing the database through a JdbcTemplate configured as a datasource bean in our application context file.

Some relevant snippets:

from application-context.xml

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="legacyDataSource" />
</bean>

<bean id="jobsheetLocation" class="java.lang.String">
    <constructor-arg value="${jobsheet.location}"/>
</bean>

<bean id="legacyDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.legacy.driverClassName}" />
    <property name="url" value="${jdbc.legacy.url}"/>
    <property name="password" value="-------------" />
</bean>

from our build properties

jdbc.legacy.driverClassName=sun.jdbc.odbc.JdbcOdbcDriver
jdbc.legacy.url=jdbc:odbc:Driver\={Microsoft Access Driver (*.mdb)};Dbq\=@LegacyDbPath@;DriverID\=22;READONLY\=true

Any thoughts?


try appending your url with

 UID\=user;PWD\=pwd
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜