what does the method Class.forName returns?
Answers were Sorted based on User's Feedback
Answer / m.gangadhar
Example
Class.forName("oracle.jdbc.driver.OracleDriver")
first it loads th class name at run time
second it executes the static initializer containg the code
of driver class i.e
static
{
try{
DriverManager.registerDriver(new Driver());
}
catch(Exception e){}
}
then it creates the object for the driver class and
registers that object in to the DriverManager
| Is This Answer Correct ? | 15 Yes | 1 No |
Answer / priyank jain
Static method Class.forName(String className) returns the
Object for the classname specified in argument passed to
method.
Also Class.forName used to load drivers.
Ex. In JDBC call
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
automatically creates an instance of a EmbeddedDriver and
registers it with the DriverManager.
| Is This Answer Correct ? | 15 Yes | 5 No |
Answer / choudarygariabbai
static Class<?> forName(String className)
Returns the Class object associated with the
class or interface with the given string name.
| Is This Answer Correct ? | 8 Yes | 2 No |
Answer / uv
When Class.forName("<classname>") function gets
executed,the class gets loaded in JVM.
To create an object and access its functions and variables,
we can use getInstance( ), please look into the below
fragment code:
Class c = Class.forName("Cls");
Object o = null;
o = c.getInstance( );
// type casting the Object
Cls cl = (Cls) o;
| Is This Answer Correct ? | 7 Yes | 1 No |
How can we store and retrieve images from the database?
What is jdbc and jpa?
How to get the data from a table into a buffer?
Write a program JDBCcode forfetching student database with SQL.
can we define indexes on a foreign key? Explain pros and cons?
What is in terms of jdbc a datasource?
Describe the steps needed to execute a sql query using jdbc.
How does a file store compare with a jdbc store?
What is connection commit?
How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.getXXX method for each column?
Explain the process of creating tables using NetBeans IDE?
What is a merge field?