Spring GetUserName method: get the user name to access the database

getUsername()

Example

public static void main(String[] args){
  String driver = "com.MysqL.jdbc.Driver";
  String url = "jdbc:MysqL://lzw:3306/testDatabase";  //创建一个表示数据库路径的字符串
  DriverManagerDataSource dmd = new DriverManagerDataSource(driver,url,"root","111");  //连接数据库
  String name = dmd.getUsername();
  System.out.println("访问数据库的用户名是:"+name);
}
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
分享
二维码
< <上一篇
下一篇>>