提示错误Exceptioninthread"main"java.lang.Error:Unresolvedcompilationproblems:Syntaxerrorontoken"InvalidCharacter",;expectedSyntaxerrorontoken"Catch",catchexpectedatTestDB...
提示错误Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "Invalid Character", ; expected
Syntax error on token "Catch", catch expected
at TestDB.main(TestDB.java:9)
程序如下
import java.sql.*;
public class TestDB {
public static void main(String[] args) {
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=pubs";
String userName = "sa";
String userPwd = "";
Connection dbConn;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!");
}
Catch (Exception e) {
e.printStackTrace();
}
}
}
谢谢 改成小写了 测试后提示如下
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
at TestDB.main(TestDB.java:9)
展开