相当于
new oracle.jdbc.driver.OracleDriver();Class.forName("oracle.jdbc.driver.OracleDriver") 用来把一个类 加载到 JVM 中,加载后 .newInstance(); 创建一个实例。
new oracle.jdbc.driver.OracleDriver();Class.forName("oracle.jdbc.driver.OracleDriver") 用来把一个类 加载到 JVM 中,加载后 .newInstance(); 创建一个实例。
解决方案 »
- JSP 用 jar文件
- 急!!!!!!!!!!!!!!!!!!!!!!我要实现一个在线书库的功能,可是显示时不知道如何显示
- myEclipse 和mysql数据库连接
- JSP连接SQL2000问题帮忙看下呀
- 页面包含变量问题!!!!!
- 送分了!
- 谁有可以检查是不是标准的xxx.xxx.xxx.xxx的IP地址的类或者方法?
- 用form target="_blank"方法打开的新窗口,怎样去掉它的地址栏啊?
- public abstract interface Servlet 中的abstract有何意义
- 网页中动态实时的显示采集的数据,有办法吗?
- 看看的俺的简历,帮帮忙
- 一个struts action问题
请问JVM是什么来的?
或者自己输入forname在jdk里帮助文档里:
forName
public static Class forName(String className)
throws ClassNotFoundException
Returns the Class object associated with the class or interface with the given string name. Invoking this method is equivalent to:
Class.forName(className, true, currentLoader)
where currentLoader denotes the defining class loader of the current class.
For example, the following code fragment returns the runtime Class descriptor for the class named java.lang.Thread: Class t = Class.forName("java.lang.Thread")
A call to forName("X") causes the class named X to be initialized.
Parameters:
className - the fully qualified name of the desired class.
Returns:
the Class object for the class with the specified name.
Throws:
LinkageError - if the linkage fails
ExceptionInInitializerError - if the initialization provoked by this method fails
ClassNotFoundException - if the class cannot be located
下面是newInstance的:newInstance
public Object newInstance()
throws InstantiationException,
IllegalAccessException
Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized.
If there is a security manager, this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package, then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException.
Returns:
a newly allocated instance of the class represented by this object.
Throws:
IllegalAccessException - if the class or its nullary constructor is not accessible.
InstantiationException - if this Class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
ExceptionInInitializerError - if the initialization provoked by this method fails.
SecurityException - if there is no permission to create a new instance.学着自己查自己看英文文档。