jdbc连接sql server2005怎么配置 jdbc连接sql server2005怎么配置 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://download.csdn.net/source/446965 String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:sqlserver://localhost:1433;DatabaseName=db"; Connection connection = null; try { Class.forName(dbDriver).newInstance(); connection = DriverManager.getConnection(url,"sa","123456"); System.out.println("成功"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); System.out.println("数据库加载失败"); } } 1. 把 jdbc 驱动包拷贝到你工程的 Web-Root/WEB-INF/lib 文件夹下.2. String dbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String url = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=user"; Connection connection = null; PreparedStatement pstmt = null; try { Class.forName(dbDriver); connection = DriverManager.getConnection(url,"sa","sa"); String preparedSql = "select * from user"; pstmt = conn.prepareStatement(preparedSql); System.out.println("连接数据库成功"); } catch (SQLException e) { e.printStackTrace(); System.out.println("连接数据库失败"); } } ExceptionInInitializerError 这问题到底怎么回事 请教一个菜鸟问题,传值问题 struts+ spring+hibernate 无法添加Action 求帮助 怎样保证两个表单的数据在一个session对象中 Tomcat 无法启动。 请问字符流和字节流有什么区别? jsp程序到linux上运行 为了生活---高分求救!! struts,应该是jsp中如何实现像qq那种抓图功能? 新手送分题目:要学JSP了,推荐本书吧。 根据string调用静态方法 jsp读数据库数据的问题
String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:sqlserver://localhost:1433;DatabaseName=db"; Connection connection = null;
try {
Class.forName(dbDriver).newInstance();
connection = DriverManager.getConnection(url,"sa","123456");
System.out.println("成功");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("数据库加载失败");
}
}
String url = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=user";
Connection connection = null;
PreparedStatement pstmt = null;
try {
Class.forName(dbDriver);
connection = DriverManager.getConnection(url,"sa","sa");
String preparedSql = "select * from user";
pstmt = conn.prepareStatement(preparedSql);
System.out.println("连接数据库成功");
} catch (SQLException e) {
e.printStackTrace();
System.out.println("连接数据库失败");
}
}