Using JDBC to connect all database

i want to create a DB layer through which i should be able to connect to the database specified at run time.how do i understand for databases like Mysql which OS-specific Driver to load at runtime.i want to make the Db layer platform independant and it should be able to talk to multiple databases.Is there a way to know at run time which drivers are available in the system.

i want to create a DB layer through which i should be
able to connect to the database specified at run
time.Fine. JDBC, reflection and some configuration settings should get you most of the way there.
how do i understand for databases like Mysql
which OS-specific Driver to load at runtime.Each RDBMS you want to support will have to have its driver available for use in the CLASSPATH.
i want
to make the Db layer platform independant and it
should be able to talk to multiple databases.Is there
a way to know at run time which drivers are available
in the system.That will be problematic. Not all RDBMS vendors are even totally ANSI SQL compliant. DDL is normally highly vendor specific, as are triggers, stored procedures, views. et. al. So, I would forewarn you that this will be a difficult task. Are you really sure that your requirements are valid?
- Saish

Similar Messages

  • How to use JDBC to connect informix database

    Dear all,
    I want my client application to connect informix database by using JDBC. The JDBC driver has been installed successfully in the client computer (Win2000). The informix 5.0 resides the a Unix server named "dbserver". The following is my java program.
    ========================
    import java.sql.*;
    import java.awt.event.*;
    public class Application1 {
    public static void main(String[] args) {
    Connection conn;
    try
    Class.forName("com.informix.jdbc.IfxDriver");
    catch (Exception e)
    System.out.println("Error "+e.getmessage());
    e.printStackTrace();
    return;
    System.out.println("It is ok");
    try
    conn = DriverManager.getConnection("jdbc:informix-sqli://dbserver:1526:INFORMIXSERVER=dbserver;username=test;password=******");
    catch (SQLException e)
    System.out.println("ERROR ."+e.getMessage());
    e.printStackTrace();
    return;
    System.out.println("All is fine");
    ===========================
    However, the error appears mentioning "Attempt to connect to database server (dbserver) failed." I don't know what the problem is because my informix database server is exactly "dbserver".
    Kindly need help from you guys. Thanks in advance.
    Kevin

    Hi,
    Plz try this (instead of 'username' use 'user') ...
    DriverManager.getConnection("jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver;user=test;password=*****");
    or this (pass the username and password as params)....
    DriverManager.getConnection( "jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver" , "test" , "*****" );
    Hope this helps
    ssa.
    >
    I want my client application to connect informix
    database by using JDBC. The JDBC driver has been
    installed successfully in the client computer
    (Win2000). The informix 5.0 resides the a Unix server
    named "dbserver". The following is my java program.
    ========================
    import java.sql.*;
    import java.awt.event.*;
    public class Application1 {
    public static void main(String[] args) {
    Connection conn;
    try
    Class.forName("com.informix.jdbc.IfxDriver");
    catch (Exception e)
    System.out.println("Error "+e.getmessage());
    e.printStackTrace();
    return;
    System.out.println("It is ok");
    try
    conn =
    onn =
    DriverManager.getConnection("jdbc:informix-sqli://dbser
    er:1526:INFORMIXSERVER=dbserver;username=test;password=
    catch (SQLException e)
    System.out.println("ERROR ."+e.getMessage());
    e.printStackTrace();
    return;
    System.out.println("All is fine");
    ===========================
    However, the error appears mentioning "Attempt to
    connect to database server (dbserver) failed." I don't
    know what the problem is because my informix database
    server is exactly "dbserver".
    Kindly need help from you guys. Thanks in advance.
    Kevin

  • I want to use jdbc to connect MS SQL SERVER

    hi,
    I want to use jdbc to connect MS SQL SERVER,not the jdbc-odbc bridge.
    I download the driver from MS,deploy it,but when I connect the database such as:
    <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");%>
    <%String sConnStr="jdbc:microsoft:sqlserver://computer2000:1433";%>
    <%Connection conn=DriverManager.getConnection(sConnStr,"sa","123");%>
    <%Statement stmt=conn.createStatement();%>
    but it said
    javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    how can i work out this problem
    maybe my configure is wrong,please give me a successful sample configuration
    thanks a lot

    Hi,
    I am not sure where you have got the following code from
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    What happens here, is Java Runtime will search for the Class named:
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    If this Class is not in the Runtime Classpath, it will throw the Error that you have got. Kindly get the proper driver as well as ensure that the Class is available in the Runtime Classpath.
    Thanks and regards,
    Pazhanikanthan. P

  • How to use JDBC to connect Tomcat with database server?(Urgent!)

    I try to deploy the tomcat and make it connect with databaser server.
    I am using mysql connector J 3.0. I added the CLASSPATH of mysql-connector-java-3.0.7-stable-bin.jar in the tomcat.sh .
    I also add the web application in server.xml.
    When I start tomcat, I can see using Classpath including mysql-connector-java-3.0.7-stable-bin.jar .
    But when i browse my jsp including the jdbc, wait for a while, I get a message as following: Timeout on server localhost. My web server and database server is same computer.
    Could you tell me what's wrong?

    Did you check to see that the MySQL database was indeed up and running, and accepting connections when you started Tomcat? Did you make sure that your firewall permits connections to the database?
    Timeout errors generally occur when you send a request to a server and the server does nothing with it - i.e., it doesn't respond to it in any way. Most firewalls are configured this way. If I telnet to your machine and I get "connection refused", I know your machine exists and I can try hacking into it. If I telnet and get nothing at all, then I will either assume either there's no actual machine at that address or it's unresponsive.

  • Use jdbc to connect servlet to oracle 8.1.6 database on win2k

    The code is below:
    package moreservlets;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /** Simple servlet used to test JDBC connection. */
    public class TitleQueries extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Connecting to Database";
    DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@pc840:1521:orcl", "scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery
    ("select ename from emp");
    while (rset.next()) {
    String name = rset.getString("ename");
    out.println(ServletUtilities.headWithTitle(title) +
    "<body bgcolor=\"#FDF5E6\">\n" +
    "<h1 align=\"center\">" + name + "</h1>\n" +
    "</body></html>");
    CLASSPATH=.;C:\J2ee;C:\j2sdkee1.3.1\lib\cloudscape;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;C:\Oracle\Ora81\orb\classes\yoj.jar;C:\Oracle\Ora81\orb\classes\share.zip
    My code cannot find the JDBC driver. Any suggestions?
    Thanks.
    I get the following errors:
    C:\J2ee\moreservlets>javac -d "C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\
    EB-INF\classes" TitleQueries.java
    TitleQueries.java:19: package oracle.jdbc.driver does not exist
    oracle.jdbc.driver.OracleDriver());
    ^
    TitleQueries.java:31: cannot resolve symbol
    symbol : variable name
    location: class moreservlets.TitleQueries
    "<h1 align=\"center\">" + name + "</h1>\n" +
    ^
    2 errors

    I changed my classpath variable and my servlet
    compiles okay with the:
    "import oracle.jdbc.driver.*" statement.
    However, I still get the following error.
    Why can't it find the jdbc driver, since it finds the
    import statement?
    Apache Tomcat/4.0.3
    Error loading driver: java.lang.ClassNotFoundException: oracle.jdbc.driver.Oracl
    eDriver
    WebappClassLoader: Resource '/WEB-INF/classes/moreservlets/ServletUtilities.cl
    ass' was modified; Date is now: Tue Jul 02 09:57:26 CDT 2002 Was: Tue Jul 02 09:
    37:20 CDT 2002
    Error loading driver: java.lang.ClassNotFoundException: oracle.jdbc.driver.Oracl
    eDriver
    CLASSPATH=.;C:\J2ee;C:\j2sdkee1.3.1\lib\cloudscape\RmiJdbc;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;C:\Oracle\Ora81\jdbc\lib\classes12.zip;C:\Oracle\Ora81\orb\classes\yoj.jar;C:\Program Files\Oracle\JDeveloper 3.2.3\jdbc\lib\oracle8.1.7\classes12.zip;C:\Oracle\Ora81\orb\classes\share.zip
    //code begins here
    package moreservlets;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.jdbc.driver.*;
    public class TitleQueries extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@pc840:1521:orcl", "scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery
    ("select * from emp");
    out.println(ServletUtilities.headWithTitle(title) +
    "<body bgcolor=\"#FDF5E6\">");
    while (rset.next()) {
    out.println("<h1 align=\"center\">"
    + rset.getString("ename") + "</h1>\n");
    out.println("</body></html>");
    catch(ClassNotFoundException cnfe) {
    System.err.println("Error loading driver: " + cnfe);
    catch(SQLException sqle) {
    System.err.println("Error connecting: " + sqle);
    }

  • How to use datasources to connect to database ?

    I have the following Problem
    I have two identical databases, one is the development database, the other one the production database.
    Now I need to find a way, how I can deploy an bc4j-application in local mode that way, that if the application is deployed to server 1 it connects to database 1 and if deployed to server 2 it connects to database 2.
    JDBC connection strings do not work as the connection is deployed with the application. So the application always connects to the same database.
    I thought datasources might be the solution. So I tried to define a datasource MyDS in the data-sources.xml file and specified it in the Configuration Wizard as the connection to use.
    But unfortunately this does not work and i do not know why:
    If I try to connect using the tester and using this datasource I get the following exception:
    Level #3: javax.naming.noInitialContextException
    Can anyone help me, what this means? How can I get around this using the BC4J Framework? Is there any "HowTo" Document which describes using datasources with BC4J?

    Frank,
    I've sorted this stuff out to some extent. Have a look at this thread:
    re:? How: multiple myAppWar.ear to use OC4J's data-sources.xml pooling?
    If this isn't all you need, then search on data-source.xml
    and read other threads also I may have posted helps on
    other threads so if you search on data-source.xml and my handle (curt504) it brings up all the threads that I posted to.
    Not to say I've solved all your problems, but I solved mine anyway. :)
    Good luck,
    curt

  • Cannot connect MS SQL Server2005 by using JDBC(JNDI) connection

    Hi all,
    I met a problem when I was trying to create a JDBC(JNDI) connection in crystal report 2008, the following error dialog shows up, it said:
    Database Connector Error: 'SQL Exceptions: [SQL State:] S1000 [Error Message:] [Microsoft][SQL Native Client]Connection is busy with results for another command'
    here is the steps how to reproduce this problem:
    1) create a DSN(Data source name) in ODBC Data Source Administrator dialog, suppose the DSN is test
        (and the DSN test show it works well)
    2) start up Crystal Report 2008, click New to create a new report, the Standard Report Creation Wizard show up
    3) expand Create New Connection node, then double click JDBC(JNDI) note
    4) the JDBC (JNDI) dialog shows up, chooose JDBC Connection in the dialog, and fill the empty fields with:
       Connection URL: jdbc:odbc:test
       Database Classname:sun.jdbc.odbc.JdbcOdbcDriver
    5) click next, it comes to the next pannel, and fill the empty fields with:
        Database: MyTestDB
        UserID: sa
        Password: sa
    6) then click Finish buttion.
    7) a new connection is created, but when I expand the new created connection, an error dialog shows up
      Database Connector Error: 'SQL Exceptions: [SQL State:] S1000 [Error Message:] [Microsoft][SQL Native Client]Connection is busy with results for another command'
    does anyone knows what's wrong with my setting? any help would be appreciated.
    Best Regards
    Tian-liang

    Hi Tian-liang,
    Try using Microsofts JDBC driver rather than Suns. Also search these forums, other have run into the same issue.
    Thank you
    Don

  • Server Exception when using JDBC to Connect with SAP

    Hello,
    I am trying to connect to a view in an external database using JDBC. When I run the TestJDBC Tool, I get the following server exception:
    com.microsoft.sqlserver.jdbc.SQLServerException: ?? ?? '<view_name>'?(?) ???????.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
        at com.sap.ip.bi.sdk.trialarea.connector.servlet.model.JDBCModel.getColumns(JDBCModel.java:202)
        at com.sap.ip.bi.sdk.trialarea.connector.servlet.controller.Control3.doPost(Control3.java:25)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
        at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
        at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
        at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
        at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
        at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
        at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
        at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
        at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
        at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
        at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
        at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
    The question marks really make it difficult to determine exactly what the issue is.
    Is there a way to perform a trace or to determine what is going on? Our third party provider has already confirmed that the authorization they provided is correct and is working.
    Thanks!

    Yes you can run a profiler trace on the SQL Server and include the "User Error Message" event under "Errors and Warnings".  This will show you the error message that SQL Server is sending to the client.
    When you get it, post it here because this is might be a bug in our JDBC driver that it does not turn that error into a sensible com.microsoft.sqlserver.jdbc.SQLServerException.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Problem using JDBC to connect to WBEM ODBC driver

    Hello,
    I've got a problem to connect to WBEM ODBC driver using JDBC. The error is:
    exception due a la requetejava.sql.SQLException: [Microsoft][WBEM ODBC Driver]Unable to connect
    When I try to connect to a MS access database, replacing only the ODBC source name, it's working. I can access to the MS access db. But when I put the WMI ODBC source name, WMI, I've got this error.
    Does anybody know what could happened? Is it possible to access to WMI through JDBC? With MS access, accessing WMI ODBC is working !
    Thanks very much for your help.
    Here is the part of the source code :
    import java.sql.*;
    import java.io.*;
    public class Main_1 {
    /** Creates a new instance of Main_1 */
    public Main_1() {
    * @param args the command line arguments
    public static void main(String[] args) {
    try {
    String url = "jdbc:odbc:WMI";
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection(url);     
    String query = "Select * from Win32_Processor";
    //String query = "Select * from test;";
    ResultSet results;
    Statement stmt = con.createStatement();
    results = stmt.executeQuery(query);
    //System.out.println (results);
    catch(Exception e){
         System.out.println("exception due a la requete" + e);
    e.printStackTrace();
    }

    you have to first start the network listener before you can run the program
    start TNSLSNR before running the jdbc program

  • How to use JDBC to connect Oracle databse

    Hi
    I try to connect the oracle databse by using JDBC. But I not sure whether is it correct or not because I learnt from the documentation provided by WWW.JAVA.SUN.
    I have create a ODBC DSN file call TKS username/password : tem/manager
    then I download the source code and enhance a bit as following :
    import java.sql.*;
    public class CreateCoffees
    public static void main(String args[])
         String url = "jdbc:oracle:thin:tem/manager@(
         description=(address_list=(
         address=(protocol=tcp)
         (host=192.9.200.8)(port=1521)))(source_route=yes)
         (connect_data=(sid=tks)))";
    Connection con;
    String createString;
    createString = "create table COFFEES " +
    "(COF_NAME VARCHAR(32), " +
    "SUP_ID INTEGER, " +
    "PRICE FLOAT, " +
    "SALES INTEGER, " +
    "TOTAL INTEGER)";
    Statement stmt;
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
         catch(java.lang.ClassNotFoundException e)
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url, "tem", "manager");
    stmt = con.createStatement();
    stmt.executeUpdate(createString);
    stmt.close();
    con.close();
         catch(SQLException ex)
         {  System.err.println("SQLException: " + ex.getMessage());
    After that I saved the file as CreateCoffees.java and compiled it
    D:\KLTAY\JAVA>javac CreateCoffees.java
    CreateCoffees.java:6: unclosed string literal
    String url = "jdbc:oracle:thin:tem/manager@(
    ^
    CreateCoffees.java:10: unclosed string literal
    (connect_data=(sid=tks)))";
    ^
    CreateCoffees.java:30: cannot resolve symbol
    symbol : variable con
    location: class CreateCoffees
    con = DriverManager.getConnection(url, "tem", "manager");
    ^
    CreateCoffees.java:31: cannot resolve symbol
    symbol : variable con
    location: class CreateCoffees
    stmt = con.createStatement();
    ^
    CreateCoffees.java:34: cannot resolve symbol
    symbol : variable con
    location: class CreateCoffees
    con.close();
    ^
    5 errors
    Please give some advise.Thanks
    best regards,
    Tay

         String url = "jdbc:oracle:thin:tem/manager@(
         description=(address_list=(
         address=(protocol=tcp)
         (host=192.9.200.8)(port=1521)))(source_route=yes)
         (connect_data=(sid=tks)))";
    After that I saved the file as CreateCoffees.java and
    compiled it
    D:\KLTAY\JAVA>javac CreateCoffees.java
    CreateCoffees.java:6: unclosed string literal
    String url = "jdbc:oracle:thin:tem/manager@(
    ^
    CreateCoffees.java:10: unclosed string literal
    (connect_data=(sid=tks)))";
    ^I would suggest putting all code between the quotesj(") on one line and then attempting to recompile.

  • How to use jdbc to connect oracle

    I want use jdbc direct to connect oracle database,and I
    want to use sun Company or oracle Company driver. how can I get driver and how do I write connection string?
    Deeply to wait your reply,thank you!

    The correct format would be jdbc:oracle:thin@server:port:sidTry "jdbc:oracle:thin:@192.168.84.20:1521:ORDB","ysys","fareast"and see what happens.
    Note that you two formats for the DriverManager.getConnection() method; if DriverManager.getConnection(db_url, username, password) doesn't work, try the other call with a fully-qualified database url:DriverManager.getConnection("jdbc:oracle:thin:ysys/[email protected]:1521:ORDB")The SID is the server ID that was given to the instance when the database was installed; default is ORCL, but may have been changed. Port default is 1521, but again, this may be different for your system.

  • -How to use JDBC to connect the SQLServer and Oracle.

    Hi,
    I create a table in the WIP DB, I want to modify this table when use "PRE-START" activity in POD.
    SAPME version: 5.2.3.4     SDK:2.0    DB:SQL2005 and Oracle 10.2g
    SourceCode like below:
    public void execute(StartHookDTO dto) throws Exception {
              initServices();
              try{
                   Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                   Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=SAPMEWIP", "sa" ,"sap12345");
                   conn.close();
              }catch(Exception e){
                   e.printStackTrace();
    Besides, I already setup the JDBC ClassPath in ConfigTool, but it gets somes error when executing.
    the error code like below:
    java.sql.SQLException: No suitable driver
    Please give me some support or a example, thank you so much!
    Br,
    Alex

    You probably want to use the WIP Datasource defined in JNDI.

  • What protocol do i use to direct connect my DATABASE? instead of TCP/IP

    I read there's a protocol (or commmand or something) to directly connect my DATABASE (in a stand alone computer).
    how do i do that?
    because Since I have no network card installed in my computer and since i have a DHCP ADSL connection (thru usb modem), i cannot connect my DATABASE (ORACLE 9.2) and Developer 6I (both in my computer). WINDOWS XP (SP2).
    is there something to fix that?
    also when i start my LISTENER as soon as i connect thru sqlplus or make 1 test with TNSPING it crashes. :(
    is that because I dont have a fixed IP?
    i 've tried using 127.0.0.1 my Internet's IP, my host, LOCALHOST, and nothing fixes it.
    HELP

    Hi,
    Try using IPC. for example something like this:
    tnsnames.ora
    TESTDB =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = testdb)
    Listener.ora would have something like this:
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
    you may also have to change your init.ora if there are references to MTS/SHARED SERVER stuff.
    cheers,
    john

  • Address book application in java using jdbc to connect to mySQL server

    hi there .....
    as clear from the topic i want to make an address book.....as above
    this is my first ever proper application of java
    i have this plan
    class GUI{* contains all components */}
    class links_GUI_to_db{* contains business logic simple enough from name */}
    then i make objects of both classes in "Main" class and all processes are done there
    as i am totally new to this thing , i would like some advice and an initial guideline on how to proceed
    i am NOT ASKING for code but advice on interaction of classes and how to proceed intitially
    thanks

    Hi,
    The answer depends pretty much on how ambitious you are, and several articels and books can be written on the topic, so it's unfortunately not something that can be fully answered in a short post.
    My best advice is that you google on MVC and on how to create layered applications. You can after that start reading e.g. JDBC tutorials and Swing tutorials (if that is the UI that you are going to use).
    Kaj
    Ps. I would probably not use MySQL as database for an address book. I would instead use a database that doesn't require installation. E.g. H2 or Derby.

  • Use listener to connect to database

    i want to use a listener to connect to an oracle database in tomcat 4, in my application web.xml y type:
    <listener>
    <listener-class>
    ResourceManagerListener2
    </listener-class>
    </listener>
    the class ResourceManagerListener2 which is in my web-inf/classes:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.jdbc.pool.*;
    public class ResourceManagerListener2 implements
         ServletContextListener {
         private OracleConnectionCacheImpl ds = null;
         public void contextInitialized(ServletContextEvent sce) {
              ServletContext application = sce.getServletContext( );
              String jdbcURL = application.getInitParameter("jdbcURL");
              String user = application.getInitParameter("user");
              String password = application.getInitParameter("password");
              String maxLimit = application.getInitParameter("maxLimit");
              try {
              ds = new OracleConnectionCacheImpl( );
              ds.setURL(jdbcURL);
              ds.setMaxLimit(Integer.parseInt(maxLimit));
              ds.setUser("principal");
              ds.setPassword("fanta");
              catch (Exception e) {
              application.log("Failed to create data source: " +
              e.getMessage( ));
              application.setAttribute("appDataSource", ds);
         public void contextDestroyed(ServletContextEvent sce) {
              ServletContext application = sce.getServletContext( );
              application.removeAttribute("appDataSource");
              // Close the connections in the DataSource
              try {
                   ds.close( );
              catch (java.sql.SQLException e) {}
              ds = null;
    and then i use a servlet to get the connection but i get an error and i don't know if the listener is working ok, the error appears in the line Connection connection = ds.getConnection(); with an exception of pointer null..... if someone can help me pleasee...
    this is my servlet:
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ConnectionServlet extends HttpServlet {
    public void doGet(
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    response.setContentType("text/html");
    Statement statement = null;
    ResultSet resultSet = null;
    String userName = null;
    try {
    ServletContext application = getServletContext( );
    DataSource ds = (DataSource) application.getAttribute("appDataSource");
    Connection connection = ds.getConnection();
    // Test the connection
    statement = connection.createStatement( );
    resultSet = statement.executeQuery(
    "select rv_domain from principal.cg_ref_codes where rownum = 1");
    if (resultSet.next( ))
    userName = resultSet.getString(1);
    catch (SQLException e) {
    out.println("DedicatedConnection.doGet( ) SQLException: " +
    e.getMessage( ) + "<p>");
    finally {
    if (resultSet != null)
    try { resultSet.close( ); } catch (SQLException ignore) { }
    if (statement != null)
    try { statement.close( ); } catch (SQLException ignore) { }
    out.println("Hello " + userName + "!<p>");
    public void doPost(
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {
    doGet(request, response);
    thanks.

    You must be joking . Please re-post that monstrosity and format it using the 'code' button above the posting window. Who on Earth can read that?
    - Saish

Maybe you are looking for

  • Lenovo Yoga 13 - Tochpad Problems / Cursor Jumps

    Hey everybody, Problem: If I rest one fingertip on my touchpad and do NOT move it, the cursor will jump in vertical direction up and down. My System: I have a Lenovo Yoga 13, i5, 8GB Ram, 128 GB SSD OS: Windows 8.1 x64 fresh install (not original Len

  • Crashes upon launching games...

    When I try launch most games on my macbook pro (early 2011) it either sits in the dock or just crashes instantly after displaying. Ive tried completelly uninstalling and reinstalling, repairing disk permissions and even completelly reinstalling the O

  • Non finalized dvd - how to recover contents?

    I have a DVD-R which contains content but wasn't finalised on the DVD recorder at time of recording. Is there any way to "grab" the content so I can play on MAC or create another DVD?

  • Control the transition

    There is a button to control the title to show/hide. If the button clicked frequently the effects will go to crazy. I add the code " anyToHide.effect.stop(); " but it doesn't work. How can I control the effects ? <mx:Transition id="anyToHide" fromSta

  • A thread on how to activate your songs!

    I had a few problems with my account a few years ago, and so made another one, the thing is i bought 69 songs on my original account which i am downloading now onto my new ps3 slim, but i have over 30 more songs on the other account and i cant for th