我应该如何将我的ms sql数据库与我的maven项目连接起来

时间:2022-10-02 21:26:32
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          <property name="driverClassName" value="com.mysql.jdbc.Driver" />
          <property name="url" value="" />
          <property name="username" value="" />
          <property name="password" value="" />
    </bean>

Mssql screen

Mssql屏幕

This is my code and the screen shot of my database .I want to use OrderInfo database. Can anyone please help me with what should be the url username and password should be?

这是我的代码和我的数据库的屏幕截图。我想使用OrderInfo数据库。任何人都可以帮助我应该是url用户名和密码应该是什么?

1 个解决方案

#1


0  

Try as :

试着:

<bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
     <property name="driverClassName" value="com.mysql.jdbc.Driver" />
     <property name="url" value="jdbc:mysql://localhost:3306/OrderInfo" />
     <property name="username" value="" />
     <property name="password" value="" />
</bean>

More Info : http://docs.spring.io/spring-data/jdbc/docs/1.1.0.M1/reference/html/orcl.datasource.html

更多信息:http://docs.spring.io/spring-data/jdbc/docs/1.1.0.M1/reference/html/orcl.datasource.html

Also you can use as below too :

您也可以使用如下:

applicationContext-dataSource.xml:

的applicationContext-dataSource.xml:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="connectionCachingEnabled" value="true"/>
</bean>
<context:property-placeholder location="classpath:jdbc.properties"/>

jdbc.properties file:

jdbc.properties文件:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/OrderInfo
jdbc.username=
jdbc.password=

#1


0  

Try as :

试着:

<bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
     <property name="driverClassName" value="com.mysql.jdbc.Driver" />
     <property name="url" value="jdbc:mysql://localhost:3306/OrderInfo" />
     <property name="username" value="" />
     <property name="password" value="" />
</bean>

More Info : http://docs.spring.io/spring-data/jdbc/docs/1.1.0.M1/reference/html/orcl.datasource.html

更多信息:http://docs.spring.io/spring-data/jdbc/docs/1.1.0.M1/reference/html/orcl.datasource.html

Also you can use as below too :

您也可以使用如下:

applicationContext-dataSource.xml:

的applicationContext-dataSource.xml:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="connectionCachingEnabled" value="true"/>
</bean>
<context:property-placeholder location="classpath:jdbc.properties"/>

jdbc.properties file:

jdbc.properties文件:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/OrderInfo
jdbc.username=
jdbc.password=