Myeclipse2013 连接不上SQL server2012
严重: Servlet.service() for servlet [selectServlet] in context with path [/HRMS] threw exception [Servlet execution threw an exception] with root cause
java.lang.Error: Unresolved compilation problem:
at com.neuedu.db.DBConnection.getConnection(DBConnection.java:12)
at com.neuedu.dept.deptselect.m.selectDAO.getDeptInfoBySelected(selectDAO.java:22)
at com.neuedu.dept.deptselect.c.selectServlet.doPost(selectServlet.java:69)
at com.neuedu.dept.deptselect.c.selectServlet.doGet(selectServlet.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
以下是我写的连接数据库的java类:
package com.neuedu.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBConnection {
private static final String URL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=HRMS";
private static final String USERNAME="sql_dota";
private static final String PASSWORD="123456";
static{
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getConnection() {
Connection conn=null;
try {
conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
} MyEclipse SQL?Server
[解决办法]
你用sql_dota帐户在查询分析器中能登录吗