java开发相关资料
来源:互联网 发布:淘宝cpu置换可靠吗 编辑:程序博客网 时间:2024/05/16 17:15
测试连接数据库 sql server 2008 R2
开发环境是 Eclipse
这个是纯Java驱动连接数据库的方式,需要下载 jdbc的驱动程序:sqljdbc4.jar 下载址址:http://good.gd/1963755.htm
Eclipse中的项目引用jar方法为:选中左侧的项目(如 test1),右键--> Properties --> Java Build Path--> Libraries --> Add External Jars -->选中刚才下载的 .jar 文件--> OK即可
---------------------------------------------------------------------------------------------
test1.java
- //import javax.swing.JOptionPane;
- public class test11 {
- public static void main(String[] args) {
- DBHelper help=new DBHelper();
- if(help.TestConn())
- System.out.println("连接成功1");
- else
- System.out.println("连接失败1");
- //JOptionPane.showMessageDialog(null, "hello world");
- }
- }
DBHelper.java
- import java.sql.*;
- import com.microsoft.sqlserver.jdbc.*;
- public class DBHelper {
- Connection dbConn = null;
- private Connection GetConn(String sUser,String sPwd) {
- try {
- String sDriverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
- //String sDBUrl = "jdbc:sqlserver://192.168.0.74;databaseName=wakeup";
- String sDBUrl = "jdbc:sqlserver://192.168.2.28\\JONSE;databaseName=wakeup";
- Class.forName(sDriverName);
- dbConn = DriverManager.getConnection(sDBUrl, sUser, sPwd);
- } catch (Exception ex) {
- //ex.printStackTrace();
- System.out.println(ex.getMessage());
- }
- return dbConn;
- }
- public boolean TestConn()
- {
- if(GetConn("sa","***")==null)
- return false;
- dbConn=null;
- return true;
- }
- }
执行结果为:
---------------------------------------------------------------------------------------------
j
j
怎么用纯java驱动方式连接SQL server 2008 R2 http://zhidao.baidu.com/question/199399735.html
Microsoft SQL Server JDBC Driver 3.0
http://www.microsoft.com/downloads/zh-cn/details.aspx?FamilyID=a737000d-68d0-4531-b65d-da0f2a735707&displayLang=zh-cn
JDBC连接SqlServer2008图解:直连(纯JAVA方式)
http://blog.csdn.net/zhouhuan965/article/details/6258035
sqljdbc2008.jar驱动 http://download.csdn.net/download/sksbbs/3460315
Java操作SQLite数据库 http://www.cxybl.com/html/bcyy/java/201110287250.html
使用纯Java JDBC驱动 程序实现数据库的连接出现错误 http://zhidao.baidu.com/question/356905375.html
如何用JAVA连接SQLite数据库? http://zhidao.baidu.com/question/206230567.html?an=0&si=9
MSDN: Sql server jdbc 纯java驱动: 使用 JDBC 驱动程序 http://msdn.microsoft.com/zh-cn/library/ms378526.aspx
eclipse添加classpath变量 http://blog.sina.com.cn/s/blog_3fe0f6250100amoh.html
通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败。错误:“Connecti... http://apps.hi.baidu.com/share/detail/43639042
用于JDBC操作数据库的公共类 http://vipbooks.iteye.com/blog/607207
java-sql数据库连接公共类文件 http://www.ineeke.com/archives/58/
Eclipse如何设置字体大小 : windows -> preference -> general -> apperance -> colors and fonts -> basic -> text font 双击它
默认字体为:Courier New 10
Eclipse 自动缩进快捷键: 全选代码,然后 Ctrl + Shift + F
- java开发相关资料
- java开发相关资料
- java flex blazeds 开发相关资料
- 驱动开发相关资料
- nes相关开发资料
- IOS开发相关资料
- android 开发相关资料
- 移动开发相关资料
- 收集的一些Java与游戏开发相关资料
- java Https 相关资料
- java缓存相关资料
- Java字节相关资料
- Java相关资料网址
- java的相关资料
- java相关资料整理
- Java相关资料
- java NIO 相关资料
- java相关资料下载
- 杨辉三角队列方式
- 深度学习相关资料
- ACM的那些故事
- 第十六周实践项目-阅读程序(2)
- HDOJ_Humble Numbers
- java开发相关资料
- Java 正则表达式的详细介绍以及实例演示
- 初实android -打招呼
- 友元函数编写运算符重载
- Linux 内核调试器内幕 —— KDB 入门指南
- iOS——socket适配ipv6,同时兼容ipv4
- java中异常处理finally和return语句的执行顺序
- 工厂模式认知
- 自我反省