Regarding DriverManager.registerDriver(...)

Hi All,
I need to test connection to a database before Data Sources can be created on it.
1. I load a driver jar from user speciifed location using URLClassLoader.
2. Then i load data source class name specified by user. For example for "oracle.jdbc.xa.client.OracleXADataSource" i do:
     Class c = loader.loadClass ("oracle.jdbc.xa.client.OracleXADataSource");
3. Now i need to load and register the driver class with DriverManager. This happens automatically had i used
Class.forName("oracle.jdbc.xa.client.OracleXADataSource") as would have created an instance and
directly loaded the driver class also.
5. So for eg: For "oracle.jdbc.xa.client.OracleXADataSource", i need to do DriverManager.registerDriver("OracleDriver");
(knowing that OracleDiver is the driver class for the datasource class mentioned.          
6. But how will i know which driver class to load given user has specified a data source class name.
For eaxmple for:               
          COM.ibm.db2.jdbc.DB2XADataSource
          com.ibm.db2j.jdbc.DB2jXADataSource
          oracle.jdbc.xa.client.OracleXADataSource
I cant use Class.forName(), as i need to load the class from the path specified by user and not default classpath.
Please help.
Regards.

Hi All,
I need to test connection to a database before Data
Sources can be created on it.
1. I load a driver jar from user speciifed location
using URLClassLoader.
2. Then i load data source class name specified by
user. For example for
"oracle.jdbc.xa.client.OracleXADataSource" i do:
Class c = loader.loadClass
ss ("oracle.jdbc.xa.client.OracleXADataSource");
3. Now i need to load and register the driver class
with DriverManager. This happens automatically had i
used
Class.forName("oracle.jdbc.xa.client.OracleXADataSour
ce") as would have created an instance and
directly loaded the driver class also.
No, loading the class into the JVM is not the same as registering it with DriverManager.
5. So for eg: For
"oracle.jdbc.xa.client.OracleXADataSource", i need to
do DriverManager.registerDriver("OracleDriver");
(knowing that OracleDiver is the driver class for
for the datasource class mentioned.Simple, call newInstance() on the class you loaded with forName() and pass that to registerDriver(). You will have to cast it as an instance of Driver.
6. But how will i know which driver class to load
given user has specified a data source class name.
For eaxmple for:               
          COM.ibm.db2.jdbc.DB2XADataSource
          com.ibm.db2j.jdbc.DB2jXADataSource
          oracle.jdbc.xa.client.OracleXADataSource
I cant use Class.forName(), as i need to load the
class from the path specified by user and not default
classpath.
Please help.
Regards.See above.
- Saish

Similar Messages

  • Memory leak in DriverManager.registerDriver()

    I am finding that when a driver is registered with the java.sql.DriverManager multiple times it runs the JVM out of memory (crashing it). I tested using the last three versions of the JDBC (thin) drivers through 8.1.7, using both Sun JDK 1.2.2 and 1.3 (final) on Linux. It takes only a 1-2 minutes to use all the memory. The following code should be sufficient to reproduce the issue:
    import java.sql.*;
    public class ClassLd {
    public static void main(String[] args) {
    try {
    while (1==1) {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    } catch (Exception e) {
    System.out.println("Error");
    e.printStackTrace();
    This produces the following error:
    Exception in thread "main" java.lang.OutOfMemoryError
    <<no stack trace available>>
    The documentation clearly states that "You register the driver only once in
    your Java application." However, a memory leak is still a nasty bug -- even if that line of documentation was skimmed.
    Thanks,
    slag
    [email protected]

    If you are concerned about registering the same driver multiple times then you should use the DriverManager.deregisterDriver() API to clean up.
    In your program the DriverManager has no choice but to hold on to all of the driver objects that you are creating and registering.

  • Difference between DriverManager.registerDriver and Class.forName?

    Hi all,
    I've noticed that the Oracle JDBC driver specifically asks to use DriverManager.registerDriver instead of Class.forName. What is the difference btw those 2 methods in loading and registering the driver?
    Thanks.

    I am trying to understand the jdbc, odbc drivers better.
    Does the class my.sql.Driver refer to a driver for MySql or is it a driver itself?
    with the lines one and two commented out, the code works fine. but with lines one and three commented out and the dbDriver being as specified in line two; no connection is made to the database. Can anyone explain this? and when i do Class.forName(dbDriver), is there a class by that name?
    //String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; //one
    //String dbDriver = "my.sql.Driver"; //two
    String dbDriver = "MySql ODBC 3.51 Driver"; //three
    String dbSource = "jdbc:odbc:mydb";
    try {
         Class.forName(dbDriver);
         conn = DriverManager.getConnection(dbSource);
         statement = conn.createStatement();
    } catch(Exception exception) {
         System.out.println(exception.getMessage()+" from the "+exception.toString());
         System.exit(1);

  • DriverManager.registerDriver  - Error

    Hello. I am new to java. i have a Class i created (on the IBM As/400 - iseries) and tried to compile - but i get this error:
    Sqlweb400.java:69: package com.microsoft.jdbc.sqlserver does not exist
    DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver));
    I have the ":CLASSPATH" as such"
    export-s CLASSPATH=/java/jt400.jar:/java/msbase.jar:/java/msutil.jar:/java/mssqlserver.jar:/java/tools.jar
    Am I missing a jar file (thast needs to be added to the classpath - put in the respective folder also)? Thanks in advance for any help, it's greatly appreciated.

    Hello. I am new to java. i have a Class i created (on the IBM As/400 - iseries) and tried to compile - but i get this error:
    Sqlweb400.java:69: package com.microsoft.jdbc.sqlserver does not exist
    DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver));
    I have the ":CLASSPATH" as such"
    export-s CLASSPATH=/java/jt400.jar:/java/msbase.jar:/java/msutil.jar:/java/mssqlserver.jar:/java/tools.jar
    Am I missing a jar file (thast needs to be added to the classpath - put in the respective folder also)? Thanks in advance for any help, it's greatly appreciated.

  • Applets: DriverManager.registerDriver  NoClassDefFoundError

    Basically, I can get a Java Program to work, but an applet with the same code fails. I'm running j2sdk 1.4.1.02 under Windows 2000, with Oracle 9i and Internet Explorer 6.0.
    CreateJoltData is just a plain Java program; JoltData is an Applet (Included below). Both use the same statement to register the Oracle Driver. It's the one that is used in all of the books and the Oracle webpages:
    DriverManager.registerDriver(new Oracle.jdbc.OracleDriver());
    I can connect and access an Oracle database from the Java program (CreateJoltData)...but not the Applet (JoltData).
    If I use the Classpath: .;C:\oracle\ora92\jdbc\lib\classes12_g.zip:
    - The program compiles and executes just fine.
    - The Java Applet compiles but gets a runtime error that usually means that the Classpath is not set correctly:
    java.lang.NoClassDefFoundError: orable/jdbc/OracleDriver.
    If I use the Classpath: .;C:\oracle\ora92\jdbc\lib\ojdbc14_g.zip
    (which Oracle recommends), both the program and the applet get a compile error:
    Package Oracle.jdbc does not exist.
    Any help would greatly be appreciated!!!
    Donna
    ------------------ JoltData.java:
    /* JoltData
    compile: javac JoltData.java
    execute: JoltData.html
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
    public class JoltData extends Applet {
    String database= "Coffee";
    String username = "Donna";
    String password = "v1v1enne";
    Connection conn=null;
    // Constructor
    public JoltData () {
    System.out.println("username " +username );
    System.out.println("password " +password );
    registerDB();
    connectDB();
    // Register Driver
    private void registerDB() {
    System.out.println("registerDB " );
    try {
    DriverManager.registerDriver(new
    oracle.jdbc.OracleDriver());
    System.out.println("registerDB done.");
    } catch (Exception e) {
    System.err.println("problems registering .");
    // Connect To Database
    private void connectDB() {
    System.out.println("connectDBURL." );
    try {
    conn = DriverManager.getConnection
    ("jdbc:oracle:oci8:@" + database,
    username,
    password);
    // Create a statement
    Statement stmt = conn.createStatement ();
    stmt = conn.createStatement();
    System.out.println("connectDB: Connection done. ");
    } catch (Exception e) {
    System.err.println("connectDB: problems connecting to
    database. ");
    public void main (String[] args) {
    JoltData converter = new JoltData ();
    }

    After much (MUCH) hair pulling, I have my Applet accessing my database (and, more troubles to come, I'm sure :-) . Without Rauf Sarwar's help, I'd probably be bald!
    Here's what the final solution is (first example line is generic; the second, is my setting):
    - Make sure that the Classpath includes an entry for the Oracle drivers:
    .;[driver].zip
    .;C:\oracle\ora92\jdbc\lib\classes12.zip
    - The subdirectory containing the java class file (executable) should also
    contain the Oracle driver.
    - HTML file needs to contain: archive=[driver].zip
    <APPLET CODE="[name].class" archive="[driver].zip ">
    <APPLET CODE="JoltData.class" archive="classes12.zip ">
    - Java.policy needs a line for SocketPermissions:
    permission java.net.SocketPermission "[hostname]", "connect,resolve";
    permission java.net.SocketPermission "Waltz", "connect,resolve";
    - Java.policy needs a line for PropertyPermission for Oracle:
    permission java.util.PropertyPermission "oracle.jserver.version",
    "read, write";
    Oh, and, in the "catch" put the following line...it helped immensely!!
    System.out.println(e.toString());
    Again, lotsa thanks goes to Rauf Sarwar for this solution!!!
    Donna

  • DriverManager.registerDriver -- can it take a variable as argument?

    While trying to make code generic, noticed that DriverManager.registerDriver takes a class like this:
    DriverManager.registerDriver (new oracle.jdbc.OracleDriver ());How does one make the argument a variable? The intent is to make the code read properties file, determine what kind of RDB and use the appropriate class. I don't want to use switch or if-then-else at this point.
    Thanks
    Murthy

    I think the registerDriver method is intended to be called by the driver's themselves.
    When the driver class gets loaded, they get registered to the DriverManager.
    So, you can always read the driver classname from a properties file and call
    Class.forName(<drivername>);
    to register the driver.
    And this is what most J2EE containers do.
    Does this answer your question.
    Vijay

  • DriverManager.registerDriver(....) doesnt work

    I have a javabean which is called from webforms on a when-button-pressed trigger. The javabean works fine, except when it reaches a point in the code where i try to load the oracle jdbc driver:
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver())
    when it hits this line, the program just hangs there, no error messages of any kind. Plus, I have tried running the same code in a standalone java application, and it works just fine.
    If you have experienced this, or know why this might be happening, please let me know, your help is appreciated.

    Class not found means as it suggests that the Forms client does not have access to all the classes it needs - in your Archive / archive_jini setting in the Formsweb.cfg file you will need to ensure that you include the JAR file that includes the JDBC runtime stuff as well as the jar file that contains your bean.
    In JDeveloper you can create a new deployment profile to create a simple JAR file. In the settings for this deployment you can specify that the JAR should include dependant classes so you can combine the JDBC and Bean classes into a single JAR.
    For information on Jar File signing for Forms see the new white paper on the Forms Page on otn
    http://otn.oracle.com/products/forms

  • Regarding execution of pl/sql procedure using JSP

    HI all
    Please help me.
    i am customizing a jsp page ,which is executing one sql procedure first then selecting data from the table in which procedure is inserting.
    How can i pass parameter dynamically to the sql procedure ? ,which i am getting from an HTML page.
    Please help me out.
    regards
    satendra

    this is the sample code provided by oracle.
    * This sample shows how to call PL/SQL blocks from JDBC.
    import java.sql.*;
    class PLSQL
    public static void main (String args [])
    throws SQLException, ClassNotFoundException
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String url = "jdbc:oracle:oci8:@";
    try {
    String url1 = System.getProperty("JDBC_URL");
    if (url1 != null)
    url = url1;
    } catch (Exception e) {
    // If there is any security exception, ignore it
    // and use the default
    // Connect to the database
    Connection conn =
    DriverManager.getConnection (url, "scott", "tiger");
    // Create the stored procedures
    init (conn);
    // Cleanup the plsqltest database
    Statement stmt = conn.createStatement ();
    stmt.execute ("delete from plsqltest");
    // Close the statement
    stmt.close();
    // Call a procedure with no parameters
    CallableStatement procnone = conn.prepareCall ("begin procnone; end;");
    procnone.execute ();
    dumpTestTable (conn);
    procnone.close();
    // Call a procedure with an IN parameter
    CallableStatement procin = conn.prepareCall ("begin procin (?); end;");
    procin.setString (1, "testing");
    procin.execute ();
    dumpTestTable (conn);
    procin.close();
    // Call a procedure with an OUT parameter
    CallableStatement procout = conn.prepareCall ("begin procout (?); end;");
    procout.registerOutParameter (1, Types.CHAR);
    procout.execute ();
    System.out.println ("Out argument is: " + procout.getString (1));
    procout.close();
    // Call a procedure with an IN/OUT prameter
    CallableStatement procinout = conn.prepareCall ("begin procinout (?); end;");
    procinout.registerOutParameter (1, Types.VARCHAR);
    procinout.setString (1, "testing");
    procinout.execute ();
    dumpTestTable (conn);
    System.out.println ("Out argument is: " + procinout.getString (1));
    procinout.close();
    // Call a function with no parameters
    CallableStatement funcnone = conn.prepareCall ("begin ? := funcnone; end;");
    funcnone.registerOutParameter (1, Types.CHAR);
    funcnone.execute ();
    System.out.println ("Return value is: " + funcnone.getString (1));
    funcnone.close();
    // Call a function with an IN parameter
    CallableStatement funcin = conn.prepareCall ("begin ? := funcin (?); end;");
    funcin.registerOutParameter (1, Types.CHAR);
    funcin.setString (2, "testing");
    funcin.execute ();
    System.out.println ("Return value is: " + funcin.getString (1));
    funcin.close();
    // Call a function with an OUT parameter
    CallableStatement funcout = conn.prepareCall ("begin ? := funcout (?); end;");
    funcout.registerOutParameter (1, Types.CHAR);
    funcout.registerOutParameter (2, Types.CHAR);
    funcout.execute ();
    System.out.println ("Return value is: " + funcout.getString (1));
    System.out.println ("Out argument is: " + funcout.getString (2));
    funcout.close();
    // Close the connection
    conn.close();
    // Utility function to dump the contents of the PLSQLTEST table and
    // clear it
    static void dumpTestTable (Connection conn)
    throws SQLException
    Statement stmt = conn.createStatement ();
    ResultSet rset = stmt.executeQuery ("select * from plsqltest");
    while (rset.next ())
    System.out.println (rset.getString (1));
    stmt.execute ("delete from plsqltest");
    rset.close();
    stmt.close();
    // Utility function to create the stored procedures
    static void init (Connection conn)
    throws SQLException
    Statement stmt = conn.createStatement ();
    try { stmt.execute ("drop table plsqltest"); } catch (SQLException e) { }
    stmt.execute ("create table plsqltest (x char(20))");
    stmt.execute ("create or replace procedure procnone is begin insert into plsqltest values ('testing'); end;");
    stmt.execute ("create or replace procedure procin (y char) is begin insert into plsqltest values (y); end;");
    stmt.execute ("create or replace procedure procout (y out char) is begin y := 'tested'; end;");
    stmt.execute ("create or replace procedure procinout (y in out varchar) is begin insert into plsqltest values (y); y := 'tested'; end;");
    stmt.execute ("create or replace function funcnone return char is begin return 'tested'; end;");
    stmt.execute ("create or replace function funcin (y char) return char is begin return y || y; end;");
    stmt.execute ("create or replace function funcout (y out char) return char is begin y := 'tested'; return 'returned'; end;");
    stmt.close();
    }

  • Problems with setting DriverManager.getConnection as a variable

    HI,
    I was wondering if someone could help me out with a problem i have. I am trying to read in the url, user name and password from an external file, and then add it to con = DriverManager.getConnection(IN HERE);
    I know that i can connect to the database and retrieve information by entering the connection in the following format: ("jdbc:mysql://url:3306/database","userName","password"). But i want to be able to read this line from an external file. When trying to do so i keep getting back the following error in the console window:
    Exception in thread "main" java.sql.SQLException: No suitable driver found for "jdbc:mysql://url:3306/database","userName","password"
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:207)
    at fast.JDBC.openDB(JDBC.java:68)
    at fast.JDBC.main(JDBC.java:40)
    Any help with this would be appreciated!
    I am using the following code:
    public class JDBC { private Connection con; public static String filePath = "C:\\Users\\Documents\\Connector.txt"; public static String sql = ("SELECT * FROM users"); public String readFileAsString(String filePath) throws IOException { //Read connector from a file byte[] connectionDB = new byte[(int) new File(filePath).length()]; BufferedInputStream f = new BufferedInputStream(new FileInputStream(filePath)); f.read(connectionDB); return new String (connectionDB); }//Close readFileAsString public static void main (String[] Args) throws Exception { JDBC j = new JDBC(); j.openDB(); j.readDB(sql); //System.out.println(j.readFileAsString(filePath)); } /** * Process for creating a connection to a database * @return * @throws Exception */ public boolean openDB() throws Exception { boolean connected = false; JDBC j = new JDBC(); String connectionDB = j.readFileAsString(filePath); System.out.println(connectionDB); //Load Drive Class.forName("com.mysql.jdbc.Driver"); //Establish connection to database try { con = DriverManager.getConnection(connectionDB); } finally { connected = true; } return connected; }//close openDB

    This is what I did for my OracleDb which required that I download a driver from the Oracle Site. You install the driver and then link the driver through the DriverManager object. It looks like your using a local JDB database - which I have never had to make use of. Here is my code for the OraceXE database. Hope this helps.
    Public Class GenericCnn Object
    private String _urlDbCnn       = "";   // the JDBC url to the database
    private String _username       = "";   // a valid username to access the database
    private String _password       = "";   // a valid password to access the database
    private String _dbDriver       = "";   // a valid JDBC driver
    private Connection _cnn            = null; // this will be the active connection
    private String _sqlStatement   = null; // this will be the statement to execute against the database
    public DbConnection(){
    this("oracle.jdbc.OracleDriver",
    "jdbc:oracle:thin:@//192.168.15.200:1521/xe",
    "usernamehere,
    "passwordhere");
    } // constructor - nothing
    public DbConnection(String nwDbDriver, String nwDbURL,
    String nwDbUsername, String nwDbPassword){
    this.setDbDriver(nwDbDriver);
    this.setUrlDbCnn(nwDbURL);
    this.setUsername(nwDbUsername);
    this.setPassword(nwDbPassword);
    } // constructor - DbDriver, DbUrl, DbUser, DbPassword
    private void initializeConnection(){
    // try - get database driver
    try{
    DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
    // try - initialize the database connection
    try{
    this._cnn = DriverManager.getConnection(this._urlDbCnn,
    this._username,
    this._password);
    }catch(SQLException e){
    ErrorTrap trap = new ErrorTrap(ErrorTrapMessage.DataConnectionNotIntitialized, e);
    } // catch - try and initialize the database connection
    }catch(SQLException e){
    ErrorTrap trap = new ErrorTrap(ErrorTrapMessage.DataConnectionDriverFailedToLoad, e);
    } // catch - try and get database driver
    } // method - OpenConnection
    .. executeTransaction -> calls initializeConnection
    .. executeQuery - > calls initialzieConnection
    .. properties
    Edited by: Monkey247 on Jan 26, 2010 10:27 AM

  • DriverManager cannot be resolved

    plz help me with this one
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 83 in the jsp file: /form.jsp
    DriverManager cannot be resolved
    80: </head>
    81:
    82: <body>
    83: <% DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    84: Connection conn=DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1522:XE","system","786313");

    ok at the moment i don't think there is problem with sql,my jsp is not getting connected to oracle.
    i did this now
    <body>
    <% DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn=DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1522:XE","system","786313");
    String first_name = request.getParameter("firstName");
    String last_name = request.getParameter("lastName");
    String address = request.getParameter("address");
    String country = request.getParameter("country");
    String email = request.getParameter("email");
    Statement stmt=conn.createStatement();
    //String queryinsert =
    //stmt.executeQuery("INSERT INTO customer (cust_id,cust_first_name,cust_last_name,cust_address, cust_country,cust_email)VALUES(custId,firstname,lastname ,address ,country ,email)");
    //String update =
    //stmt.executeQuery("UPDATE customer SET (cust_first_name  = first_name ,cust_last_name = last_name  ,cust_address =address ,cust_country = country,cust_email = email )WHERE (cust_first_name = first_name AND cust_last_name = last_name)") ;
    stmt.close();
    conn.close(); %>i m getting this error
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    Stacktrace:
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • Java.lang.ClassCastException at DriverManager.getConnection

    Hi all,
    i need to connect to SQL server DB which exist on a server
    and java.lang.ClassCastException appear when executing the line
    Connection conn = (Connection)DriverManager.getConnection(url,username,password);
    the following is the code which i use:
    String serverName = "64.15.155.101";
    String portNumber = "1433";
    String mydatabase = "MMSMS";
    String username = "u";
    String password = "p";
    // Step 1: Load the JDBC driver.
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    // Step 2: Establish the connection to the database.
    String url = "jdbc:sqlserver://"+serverName
    +";databaseName="+mydatabase;
    System.out.println(url);
    DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
    Connection conn = (Connection)DriverManager.getConnection(url,username,password);
    System.out.println("connection succesful");

    Why are you casting there? Do you have a class named Connection in your own code?
    It would seem so.
    Do this
    java.sql.Connection conn = DriverManager.getConnection(url,username,password);You shouldn't need a cast there. So the fact you are using one suggests that you had an earlier problem with a conflict with a Connection class of your own.

  • Needed help regarding converting  string to java.sql.Date format

    I have a a function which returns a calendar object. The date must be inserted to Oracle DB using java.sql.Date format.
    So i have converted the Calendar object to java.sql.Date format using the following code
    java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());But while getting inserted into the DB it was in mm/dd/yyyy format whereas i wanted dd/mm/yyyy format
    Can any body please help out how to store the date in dd/mm/yyyy format ?

    Can u please explain this a bit
    This is my code
    public int addBook(List<Book> BookList) throws SQLException, ParseException{
              System.out.println("Hi there");
              Book book = new Book();
              BookDB bookDb = new BookDB();
              //listLength =      BookList.length;
              String bookId = null;
                   try{
                        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                        con  = DriverManager.getConnection("jdbc:oracle:thin:@10.123.79.195:1521:findb01","e115314", "e115314");
                        addBook = con.prepareStatement("insert into ABC_Book values(?,?,?,?,?,?,?)");
                        Iterator<Book> iterator = BookList.iterator();
                        while(iterator.hasNext()){
                             book = (Book)iterator.next();
                             System.out.println(book.getBookId());
                             addBook.setString(1,book.getBookId());
                             addBook.setString(2,book.getTitle());
                             addBook.setString(3,book.getAuthor());
                             addBook.setString(4,book.getPublisher());
                             System.out.println(book.getPublicationDate());
                             System.out.println("Before Date");
                             System.out.println("book.getPublicationDate().getTime()"+book.getPublicationDate().getTime());
                             java.sql.Date publicationDate = new java.sql.Date(book.getPublicationDate().getTime().getTime());
                             SimpleDateFormat formatter = new SimpleDateFormat("dd/mm/yyyy");
                             dateString = formatter.format(publicationDate);
                             System.out.println("Today is"+dateString);
                             java.sql.Date date = (java.sql.Date)formatter.parse(dateString);
                             System.out.println("date"+date);
                             //java.sql.Date publicationDate = (Date)book.getPublicationDate().getTime();
                             //System.out.println("Value of date is"+publicationDate);
                             System.out.println("After Date");
                             addBook.setDate(5,publicationDate);
                             addBook.setString(6,book.getCountry());
                             addBook.setString(7,book.getLanguage());
                             rs = addBook.executeQuery();
                             //con.commit();
                             rowCount = rowCount + rs.getRow();
                        return rowCount;
                   catch(SQLException se){
                        se.printStackTrace();
                   finally{
                        con.close();
                        System.out.println("After adding ");
              return 0;
         }

  • How does Class.forName() get a driver registered with DriverManager

    From the documentation, Class.forName() tends to loads the specified class via the class loader. But if we use it to load the class of a jdbc connection driver, how does it get automatically registered with DriverManager?
    Neerav

    yorkroad wrote:
    No. Class.ForName("whatever") intializes the class. As for registering it with the DriverManager, this is from the API:
    When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.
    You could use DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); which does it all in one. (Although keep in mind that will require an Oracle import in your code!)
    m
    Edited by: yorkroad on Nov 4, 2009 3:42 PMNo, loading the Class with Class.forName already registers the driver, as already said. Where DriverManager "searches" is among those registered classes. The method detailed above does not do anything more than simply calling Class.forName() with the added drawback that the Driver jarfile must be present at compile time, and, in order to change DBs you would have to change and recompile your code.

  • JDBC:Class.forName() Vs registerDriver()

    can anyone tell me the difference between Class.forName() and registerDriver()?

    Genarlly the former calls the latter.
    JDBC drivers have a static intialiser which calls DriverManager.registerDriver() on themselves.
    Since there's no way to call registerDriver on a class without loading the class (and therefore, normally, having already had it call registerDriver) there's almost never a need to call it yourself.

  • EP5.0 Custom .par File Does Not Work in EP6.0 SP2

    I have a .par file called CustomerSearch.par that is used in EP5.0, and I am now trying to get this .par file to work in EP6.0 SP2.  I noticed the directory structure changes, so my .par structure is this:
    CustomerSearch.par
    -->  portal-inf
    portalapp.xml
    lib
    CustomerSearch.jar
    TableViewExample.class
    pagelet
    TableView.jsp
    I am getting the following error in the portal console logs when I try to access the component after I have uploaded the CustomerSearch.par file.  Does anyone have any suggestions?
    Error Message
    Jan 26, 2005 4:23:50 PM # Client_Thread_34 Fatal Exception ID:04:23_26/01/05_0019
    com.sapportals.portal.prt.component.PortalComponentException: Error in service call of Resource
    Component : CustomerSearch.TableViewExample
    Component class : TableViewExample
    User : testUser
    at com.sapportals.portal.prt.core.PortalRequestManager.handlePortalComponentException(PortalRequestManager.java:858)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:389)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:462)
    at com.sapportals.portal.prt.component.AbstractComponentResponse.include(AbstractComponentResponse.java:88)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:226)
    at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:109)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:135)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:300)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:190)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:209)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:576)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:300)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:190)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:669)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:208)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:532)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
    at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
    at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:665)
    at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:312)
    at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
    at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1229)
    at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
    at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
    at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    Caused by: com.sapportals.portal.prt.component.PortalComponentException: PortalComponentException
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.run(JSPCompiler.java:123)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.compileJSP(JSPComponentItem.java:224)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:86)
    at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:338)
    at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:817)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:385)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:462)
    at com.sapportals.portal.prt.component.AbstractComponentResponse.include(AbstractComponentResponse.java:88)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:226)
    at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:109)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:135)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:300)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:190)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:209)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:576)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:300)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:190)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:669)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:208)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:532)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
    at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
    at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:665)
    at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:312)
    at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
    at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1229)
    at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
    at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
    at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    Caused by: com.sapportals.portal.prt.servlets_jsp.server.compiler.CompilingException: D:/usr/sap/EPD1/j2ee/j2ee_22/cluster/server/services/servlet_jsp/work/jspTemp/irj/root/WEB-INF/portal/portalapps/CustomerSearch/work/pagelet/_sapportalsjsp_TableView.java:39: cannot resolve symbol
    symbol : class MyBean
    location: package TableViewExample
    TableViewExample.MyBean myBeanName = null;
    ^
    D:/usr/sap/EPD1/j2ee/j2ee_22/cluster/server/services/servlet_jsp/work/jspTemp/irj/root/WEB-INF/portal/portalapps/CustomerSearch/work/pagelet/_sapportalsjsp_TableView.java:41: cannot resolve symbol
    symbol : class MyBean
    location: package TableViewExample
    myBeanName = (TableViewExample.MyBean)pageContext.getAttribute("myBeanName", PageContext.APPLICATION_SCOPE);
    ^
    D:/usr/sap/EPD1/j2ee/j2ee_22/cluster/server/services/servlet_jsp/work/jspTemp/irj/root/WEB-INF/portal/portalapps/CustomerSearch/work/pagelet/_sapportalsjsp_TableView.java:45: cannot resolve symbol
    symbol : class MyBean
    location: package TableViewExample
    myBeanName = (TableViewExample.MyBean) Beans.instantiate(this.getClass().getClassLoader(), "TableViewExample.MyBean");
    ^
    3 errors
    at com.sapportals.portal.prt.servlets_jsp.server.compiler.JavaCompiler.compileExternal(JavaCompiler.java:439)
    at com.sapportals.portal.prt.servlets_jsp.server.compiler.JavaCompiler.compile(JavaCompiler.java:539)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPParser.parse(JSPParser.java:2140)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.compile(JSPCompiler.java:76)
    at com.sapportals.portal.prt.servlets_jsp.server.jsp.JSPCompiler.run(JSPCompiler.java:118)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.compileJSP(JSPComponentItem.java:224)
    at com.sapportals.portal.prt.core.broker.JSPComponentItem.getComponentInstance(JSPComponentItem.java:86)
    at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.service(PortalComponentItemFacade.java:338)
    at com.sapportals.portal.prt.core.broker.PortalComponentItem.service(PortalComponentItem.java:817)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:385)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:462)
    at com.sapportals.portal.prt.component.AbstractComponentResponse.include(AbstractComponentResponse.java:88)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:226)
    at com.sapportals.portal.htmlb.page.JSPDynPage.doOutput(JSPDynPage.java:76)
    at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:109)
    at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:135)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
    at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:300)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:190)
    at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:209)
    at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:576)
    at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:300)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:138)
    at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:190)
    at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:669)
    at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:208)
    at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:532)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:415)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.InvokerServlet.service(InvokerServlet.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.inqmy.services.servlets_jsp.server.RunServlet.runSerlvet(RunServlet.java:149)
    at com.inqmy.services.servlets_jsp.server.ServletsAndJspImpl.startServlet(ServletsAndJspImpl.java:833)
    at com.inqmy.services.httpserver.server.RequestAnalizer.checkFilename(RequestAnalizer.java:665)
    at com.inqmy.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:312)
    at com.inqmy.services.httpserver.server.Response.handle(Response.java:173)
    at com.inqmy.services.httpserver.server.HttpServerFrame.request(HttpServerFrame.java:1229)
    at com.inqmy.core.service.context.container.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:36)
    at com.inqmy.core.cluster.impl5.ParserRunner.run(ParserRunner.java:55)
    at com.inqmy.core.thread.impl0.ActionObject.run(ActionObject.java:46)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.inqmy.core.thread.impl0.SingleThread.run(SingleThread.java:148)
    [email protected]7 #
    TableViewExample.java Code
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Vector;
    import com.sapportals.htmlb.InputField;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.event.TableNavigationEvent;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.htmlb.table.DefaultTableViewModel;
    import com.sapportals.htmlb.table.TableView;
    import com.sapportals.htmlb.table.TableViewModel;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.prt.component.*;
    public class TableViewExample extends PageProcessorComponent
         /* (non-Javadoc)
    @see com.sapportals.portal.htmlb.page.PageProcessorComponent#getPage()
         public DynPage getPage()
              return new MyDynPage();
         public class MyDynPage extends JSPDynPage
              //variables
              private int visibleRow = 1;
              public String search;
              public String state = "0";
              MyBean myBean;
              /* (non-Javadoc)
    @see com.sapportals.htmlb.page.DynPage#doInitialization()
              //Get Context and Initialize Bean
              public void doInitialization() throws PageException
                   IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                   IPortalComponentContext myContext = request.getComponentContext();
                   IPortalComponentProfile myProfile = myContext.getProfile();
                   IPortalComponentProfile userProfile = request.getComponentContext().getProfile();
                   MyBean myBean = new MyBean();
                   myBean.setText("");
                   myProfile.putValue("myBeanName", myBean);
              /* (non-Javadoc)
    @see com.sapportals.htmlb.page.DynPage#doProcessAfterInput()
               //Called Directly After The Data Was Submitted
              public void doProcessAfterInput() throws PageException
                   //Get the Bean Object
                   IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                   IPortalComponentContext context = request.getComponentContext();
                   IPortalComponentProfile profile = context.getProfile();
                   //Get the Account Info Input Field
                   InputField myInputField = (InputField) getComponentByName("account_input");
                   if( myInputField != null )
                        search = myInputField.getValueAsDataType().toString();
                   myBean = (MyBean) profile.getValue("myBeanName");
                   myBean.setAccount(search);
                   myBean.MyBeanModel();
                   state = myBean.state;
                   if( state == "1" )
                        //get the selected row / rows
                        //get the tableView by getComponentByName
                        TableView table = (TableView) this.getComponentByName("myTableView");
                        //Get the first visible row
                        int firstVisibleRow = table.getVisibleFirstRow();
                        //Get the last visible row
                        int lastVisibleRow = table.getVisibleLastRow();
                        //which of the visible rows was selected
                        StringBuffer strBuff = new StringBuffer();
                        for( int i = firstVisibleRow; i <= lastVisibleRow; i++ )
                             if( table.isRowSelected(i) )
                                  strBuff.append("Row: " + i + " : ");
              /* (non-Javadoc)
    @see com.sapportals.htmlb.page.DynPage#doProcessBeforeOutput()
              //Called Directly Before Output - Last Called Function
              public void doProcessBeforeOutput() throws PageException
                   //set the jsp to load
                   this.setJspName("TableView.jsp");
              //Called If The Navigation Event Was Send
              //The JSP has set the navigation mode byline so the user can navigate
              //line by line, page up and down, first and last entry
              public void onNavigation(Event event)
                   if( state == "1" )
                        //Navigation - get the event to recover the actual position
                        TableNavigationEvent tne = (TableNavigationEvent) event;
                        //With the event the method getFirstVariableRowAfter() can be used
                        //which gives the acutal position (after the event)
                        this.visibleRow = tne.getFirstVisibleRowAfter();
                        if( myBean != null )
                             //just for the first time, when there is no bean
                             //set the new visibleRow
                             myBean.setVisibleRow(new Integer(this.visibleRow).toString());
              public void onSendButtonClicked(Event event) throws PageException
                   IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                   IPortalComponentContext context = request.getComponentContext();
                   IPortalComponentProfile myProfile = context.getProfile();
                   IPortalComponentProfile userProfile = request.getComponentContext().getProfile();
                   myBean = (MyBean) myProfile.getValue("myBeanName");
                   state = "1";
                   myBean.setState("1");
                   myProfile.putValue("myBeanName", myBean);
         public class MyBean
              //Properties
              public DefaultTableViewModel model;
              private String visibleRow = "1";
              private String text;
              private String account;
              private String state = "0";
              private String searchType;
              //get/set account
              public void setAccount(String account)
                   this.account = account;
              public String getAccount()
                   return this.account;
              //get/set state
              public void setState(String state)
                   this.state = state;
              public String getState()
                   return this.state;
              //get/set model
              public void setModel(DefaultTableViewModel model)
                   this.model = model;
              public TableViewModel getModel()
                   return this.model;
              //get/set Text for status messages
              public void setText(String text)
                   this.text = text;
              public String getText()
                   return this.text;
              //get/set VisibleRow for tableView
              public void setVisibleRow(String visibleRow)
                   this.visibleRow = visibleRow;
              public String getVisibleRow()
                   return this.visibleRow;
              //get/set SearchType
              public void setSearchType(String searchType)
                   this.searchType = searchType;
              public String getSearchType()
                   return this.searchType;
              //Create Table View Model
              public void MyBeanModel()
                   model = this.createNewTable(model);
                   //Set Table Text
                   if( model.getRowCount() > 0 )
                        this.setText("Customer Information Found For: " + this.getSearchType());
                   else
                        this.setText("No Records Found For Account: " + this.getAccount());
              //Create Data For A DefaultTableViewModel By Using Vector
              private DefaultTableViewModel createNewTable(DefaultTableViewModel model)
                   //Get a vector with a filled up data array
                   Vector data = null;
                   try
                        data = doGet();     
                   catch( ClassNotFoundException e )
                        e.printStackTrace();
                   //Get a new vector for the titles
                   Vector colName = new Vector();
                   colName.addElement("NUMBER");
                   colName.addElement("CUSTOMER NAME");
                   colName.addElement("PHONE");
                   colName.addElement("STREET");
                   colName.addElement("CITY");
                   colName.addElement("STATE");
                   colName.addElement("ZIP");
                   model = new DefaultTableViewModel(data, colName);
                   return model;
              //Method will execute SQL string with search parameter on the database
              public Vector doGet() throws ClassNotFoundException
                   Statement stmt = null;
                   Vector myVector = new Vector();
                   try
                        //Load the sun jdbc-odbc bridge driver
                        DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
                        String dbUrl = "jdbc:oracle:oci8:@testX003";
                        Connection con = DriverManager.getConnection(dbUrl, "test", "test");
                        //Create a statement to submit SQL statements to the driver
                        stmt = con.createStatement();
                        String query = "select PAYER_NUM, PAYER_CUST_NAME, PAYER_PHONE_NUM_1 " +
                                          "PAYER_STR_ADDR, PAYER_CITY_NAME, PAYER_ST_ABBR, PAYER_ZIP_CD " +
                                          "from CUST_PAYER where PAYER_NUM = " + this.getAccount() + "";
                        this.setSearchType("Payer Search");
                        ResultSet rs;
                        rs = stmt.executeQuery(query);
                        ResultSetMetaData rsmd = rs.getMetaData();
                        //Get number of columns
                        int numCols = rsmd.getColumnCount();
                        if( numCols == 0 )
                             query = "select SLDTO_NUM, SLDTO_CUST_NAME, SLDTO_PHONE_NUM_1 " +
                                       "SLDTO_STR_ADDR, SLDTO_CITY_NAME, SLDTO_ST_ABBR, SLDTO_ZIP_CD " +
                                       "from CUST_PAYER where SLDTO_NUM = " + this.getAccount() + "";
                             this.setSearchType("SoldTo Search");
                             rs = stmt.executeQuery(query);
                        myVector = createData(rs);
                        //Close ResultSet
                        rs.close();
                        //Close Statement
                        stmt.close();
                        //Close Connection
                        con.close();
                   catch( SQLException ex)
                        this.account = ex.getMessage();
                   return myVector;
              //This method pulls the database selection results and places them into vectors
              private Vector createData(ResultSet res) throws SQLException
                   //Get the metadata infro
                   ResultSetMetaData rsmd = res.getMetaData();
                   //Get number of columns
                   int numCols = rsmd.getColumnCount();
                   String checkVal;
                   //Loop through the result set and load rows of data into Vector
                   Vector dataVec = new Vector();
                   Vector retVector = new Vector();
                   int k = 0;
                   while( res.next() )
                        k++;
                        for( int i = 1; i

    Hi Bernhard,
    nice to hear that we resolve the problem
    > Karstens answer solved my base problem,
    > Detlevs answer lead into the right direction.
    Not that I've that need for points...
    It's just the question why my answer (if you follow the link, my answer was: delete two lines, from which one is essential to be deleted) only "lead into the right direction"... In fact, it solved the base problem, I would claim for me
    To give the technical background: If your write
    <property name="ComponentType" value="jspnative"/>
    the portal runtime expects a component consisting of a native JSP; the second directive -
    <property name="JSP" value="pagelet/InitialPage.jsp"/>
    - for this case tells where to find this JSP. So if you delete the first line, <i>at least</i> the second line has no sense anymore. To clean up such a portalapp.xml, it just makes sense also to delete the second line.
    Best regards
    Detlev

Maybe you are looking for

  • I want a new Macbook!

    Dear friends, at the beginning of the November my friends will be in New-York. I want to buy extended configuration of new MacBook Air (13 in., i7 1.8). As I understand this configuration is not available in retail Apple Stores and should be pre orde

  • I read that Chrome was dropping npapi support - In the article it said that firefox was in December. Is this true? I cannot find a source.

    I read that Chrome was dropping npapi support - In the article it said that firefox was in December. Is this true? I cannot find a source.

  • Database query ResultSet from servlet to JSP page

              Hi there,           I have an Access 2000 database. I am running Apache and Tomcat on Windows Me.           I would like to know if it is possible for me to use a Servlet to search the           database (I know this bit is possible!), but

  • Change site name

    i've published my iWeb site to a folder on my desktop. Not to the web yet. Because for some strange reason, each time i publish (save) my site to a folder, the folder name always has an underscore at the end. I did NOT put an underscore at the end of

  • Sort Components in task list

    Dear Friends, I have 20 different components [Assigned to a header assembly] connected to a single operation 010 in general task list. Now I have sorted this components based on Item number as the default sort is based on material criteria. After sor