sql server - How should I connect my ms sql database with my maven project -
<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>
this code , screen shot of database .i want use orderinfo database. can please me should url username , password should be?
try :
<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
also can use below :
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.driverclassname=com.mysql.jdbc.driver jdbc.url=jdbc:mysql://localhost:3306/orderinfo jdbc.username= jdbc.password=
Comments
Post a Comment