相当于 
new oracle.jdbc.driver.OracleDriver();Class.forName("oracle.jdbc.driver.OracleDriver") 用来把一个类 加载到 JVM 中,加载后  .newInstance(); 创建一个实例。

解决方案 »

  1.   

    humanity(总是偷窥 Java & XML)
    请问JVM是什么来的?
      

  2.   

    Class.forName()的参数是一个类具体的物理文件,Class.forName()就是找到这个类,对于上面的代码来说,就是OracleDriver这个类, .newInstance()就是创建OracleDriver的实例。
      

  3.   

    看java基础知识。查jdk帮助文档即可知晓。
    或者自己输入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.学着自己查自己看英文文档。
      

  4.   

    我一般不要.newInstance(); 有什么分别啊~~它自己都会创建的