Below is the way to do it. By default, the Class object has a newInstance method. however, this does not accept the parameter.
We have a way to get the constructors of a class by using the getDeclaredConstructor method. This method accepts variable list of arguments
so that we can pass in the type of arguments of the constructor we would like to invoke. Sample is given below
myConnection = myConnectionClass.getDeclaredConstructor(String.class,Hashtable.class).newInstance("CONN_ID",connProps);
References
No comments:
Post a Comment