Spring geturl method: get the URL path to access the database
•
Java
getUrl()
Example
public static void main(String[]args){ String driver = "com.MysqL.jdbc.Driver"; String url = "jdbc:MysqL://lzw:3306/testDatabase"; //创建一个表示数据库路径的字符串 String username = "root"; //创建一个表示数据库用户名的字符串 String password = "111"; //创建一个表示数据库密码的字符串 DriverManagerDataSource dmd = new DriverManagerDataSource(driver,url,username,password); String accurl = dmd.getUrl(); System.out.println("访问数据库的URL是:"+accurl); }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码