简体   繁体   中英

Amazon ec2 Java mysql

I am trying to setup an Amazon EC2 with tomcat and mysql. Both are up and running, both are in same instance. My confusions is, what jdbc url I have to use to connect my database on the same instance

<bean id="masterDataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
     <property name="driverClassName">                
         <value>com.mysql.jdbc.Driver</value>       
     </property>        
     <property name="url">          
         <value>WHAT TO ADD HERE</value>                    
     </property>
     .....

Try the following:

jdbc:mysql://localhost/database_name?user=your_username&password=your_greatsqlpw

or

jdbc:mysql://127.0.0.1/database_name?user=your_username&password=your_greatsqlpw

As long as your server is secure you should not be concerned about security too much since the connections are only internal in the server.

Add them like this:

<property name="url" value="jdbc:mysql://localhost/_dbName" />
<property name="username" value="your username" />
<property name="password" value="your password" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM