尝试连接数据库时出现错误
错误:com.microsoft.sqlserver.jdbc.SQLServerConnection 无法转换为
Ptakip.Connection
- Ptakip 是我的包裹
连接是我的课
这是连接类代码;
import java.sql.*; public class Connection { private Connection cn; public Connection connector( ) { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection cn = (Connection) DriverManager.getConnection("jdbc:sqlserver://localhost\\MyServer: 1433;databaseName=TEST;user=Glassfish;password=pass;"); System.out.println("connected"); } catch(Exception ex) { System.out.println("Error:" + ex.getMessage()); System.out.println(cn); } return cn; } }