简体   繁体   中英

I am using Microsoft SQL Server 2014 and NetBeans 8.0.2 - getConnection always underlined RED

I'm hoping that you can help me?

I'm currently working on an application that will be programmed in NetBeans 8.0.2 and will have SQL Server 2014 as the backend database application.

I am trying to get the NetBeans app to talk to the SQL database app and although I feel I have run the processes of creating the linking etc. correctly, I cannot get the getConnection to any state apart from underlined RED.

Any and all help will be appreciated.

I have added my call below:

Connection con = null;   
try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=KeyProp","sa");
    System.out.println("Connected");
} catch(ClassNotFoundException e) {
    System.out.println("Class Not Found Exception :" + e.getMessage());
}

Thanks, Don

The problem is that you are trying to call a getConnection method that does not exist ( getConnection(String, String) ).

You have the following choices:

So the most likely solution is to use

getConnection("jdbc:sqlserver://...", "sa", "your-sa-password)

我不知道为什么它有下划线,但在你的连接字符串中, 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