java开发相关资料

测试连接数据库 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;
	}
	
}

执行结果为:

---------------------------------------------------------------------------------------------

java    http://wenku.baidu.com/view/f091272cb4daa58da0114ab0.html

javasqlserver2005 http://wenku.baidu.com/view/add31ec62cc58bd63186bdb8.html

 

怎么用纯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

 ---------------------------------------------------------------------------------------------

 

 

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值