注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 漂亮MM的网恋史
 帮助
2008-07-18 00:02:57
文章来源:http://www.cnblogs.com/mgod/archive/2007/10/19/931013.html
java中Class.forName的含义



Class.forName(xxx.xx.xx) 返回的是一个类, .newInstance() 后才创建一个对象 Class.forName(xxx.xx.xx);的作用是要求JVM查找并加载指定的类,也就是说JVM会执行该类的静态代码段


Class aClass = Class.forName(xxx.xx.xx);
Object anInstance = aClass.newInstance();


Class.forName("").newInstance()返回的是object
but there is some limit for this method to create instance
that is your class constructor should no contain parameters, and you should cast the instance manually.

Class Driver{
protected static Driver current;
public static Driver getDriver(){
return current;
}
}

Class MyDriver extends Driver{
static{
Driver.current=new MyDriver();
}
MyDriver(){}
}

用时:
Class.forName("MyDriver");
Driver d=Driver.getDriver();

有的jdbc连接数据库的写法里是Class.forName(xxx.xx.xx);而有一些:Class.forName(xxx.xx.xx).newInstance(),为什么会有这两种写法呢?

Class.forName(xxx.xx.xx) 返回的是..



2008-07-18 00:00:40
文章来源:http://blog.csdn.net/zhf811224/archive/2007/04/23/1575598.aspx
一、   从Oracle和Microsift网站上下载JDBC驱动程序
n         下载Oracle JDBC驱动程序
1.       网址:
http://www.oracle.com/technology/global/cn/software/tech/java/sqlj_jdbc/index.html
2.       在Eclipse安装目录,例如D:\lecture\JAVA\Eclipse\eclipse下创建路径:
D:\lecture\JAVA\Eclipse\eclipse\jdbc\OracleJDBC\lib。
3.       下载4个java归档文件放入其中:
1)       ocrs12.jar
2)       ojdbc14.jar
3)       ojdbc14dms.jar
4)       orai18n.jar
 
n         下载SQL Server 2000 Driver for JDBC Service Pack 3,支持JDK 1.4
1.       网址:
[url]http://www.micros..



2008-07-17 23:57:39
文章来源:http://support.microsoft.com/kb/313100/zh-cn
 
如何开始使用 Microsoft JDBC
察看本文应用于的产品





文章编号
:
313100

最后修改
:
2005年8月12日

修订
:
3.2

本页
概要

设置 CLASSPATH 变量

注册驱动程序




公告

背景音乐
我的音乐

00:00 | 00:00