1024programmer Java Why can’t I connect to the mysql database_java can’t connect to the database, how to solve it!

Why can’t I connect to the mysql database_java can’t connect to the database, how to solve it!

e81d54bb2e94214d57f11f8f00149ff3.png

juzhengw

I just did this last year,I will post my link code for you try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); //Load the sqlserver JDBC driver //Class .forName(“org.gjt.mm.mysql.Driver”); System.out.println(“Success loading sqlserver Driver!”); catch (Exception e) { System.out.print(“Error loading sqlserver Driver!”) “); e.printStackTrace(); } try { Connection connect = DriverManager.getConnection( “jdbc:sqlserver://localhost:1433;DataBasename=java”,”sa”,”***** **”); //Don’t worry about the address ,The user name is sa //The connection URL is jdbc:sqlserver//server address/database name , The next two parameters are the login username and password System. out.println(“Success connect sqlserver server!”); Statement stmt = connect.createStatement(); ResultSet rs = stmt.executeQuery(“select * from Users”); //user is for you Name: If you are sure that your jadc package and link code are completely correct, I guess you may have the database not set to use password login (the table is not in the database for password login). There is no specific code and it is hard to say,Thrown What’s wrong?,I only used this two or two years ago,I’m quite familiar with it,If you still can’t solve it, you can send me a private message;Xiaobai mutual encouragement

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/why-cant-i-connect-to-the-mysql-database_java-cant-connect-to-the-database-how-to-solve-it/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索