HELP IN DATABASE CONNECTIVITY IN A SERVLET`

HI there,
I have some issues in an application. I have a servlet which is called Servlet1.class. I have deployed this in my tomcat webapps folder. There is a stand alone application called MailAgent.class which pools into a mail box and retrieves the messages and converts them as HTTP messages. Then the MailAgent.class sends the HTTP message as multipart post (email message) to the servlet. In the servlet I am trying to establish a database connection with the JDBC driver from third party vendor. I am unable to get the driver class when I establish the connection with the database. Is there any issues with servlet and database access. I am able to connect if I run as a stand alone application.
Any help would be greatly appreciated.
Thanks
John

There shouldn't be any .class file in your webapps folder. I hope you mean that you created a subdirectory under webapps, with a WEB-INF under that and /classes and /lib under that. Your servlet .class file and its package directory structure belong under webapps/yourApp/WEB-INF/classes, right?
You can create database connections in a servlet, although I agree with the previous poster that you'd be better off putting database code into objects that you could test off-line, without the servlet.
You've got to have the JDBC driver JARs in the webapps/yourApp/WEB-INF/lib directory, for starters.
If you get really adventurous you can create a pooled JNDI data source, but maybe that's another day's work. Get the basic connection working first.

Similar Messages

  • How to read a passward protected excel file with the help of database connectivity tool kit

    hi, i was reading an excel file with the help of database connectivity tool kit in labview 8.0
    i made tabels in the excel file nand made odbc connection and specified the workbbok name.
    now my problem is how to read the same file if i specife a pasword to that excel file ?

    Hi,
    Check out this thread about opening a password-protected Excel file using ActiveX. This should take care of it for you!
    Amanda Howard
    Americas Services and Support Recruiting Manager
    National Instruments

  • Unable to acheive database connectivity in my servlet prog.....

    HELLO ALL......
    IM USING ORACLE 9I(ORAHOME 90) FOR MY DATABASE CONNECTIVITY..PLUS IM USING TOMCAT 5.5.7 ..... IM TRYING TO ACHIEVE CONNECTIVITY USING JDBCODBC BRIDGE....THAT IS DRIVER OF THE FIRST TYPE.....IM NOT USING THIN DRIVER.....BUT SOMEHOW MY SERVLET IS NOT ACHIEVING THE DATABASE CONNECTIVITY....IT SHOWS NO DATA SOURCE NAME FOUND AND NO DEFAULT DRIVER SPECIFIED....... I DONT KNOW WHAT THE PROBLEM IS .... I TRIED TO FIND IT ON THE NET AND APPLIED SOME OF THE MEASURES BUT NOT FRUITFUL......... ONE SOLUTION SAID THAT I NEED TO PLACE OJDBC14.JAR FILE IN MY COMMON/LIB FOLDER ...BUT IM UNABLE TO FIND THAT JAR FILE.....WHAT TO DO.. PLEASE HELP...... IM TOTALLY FRUSTRATED DUE TO WHICH IM NOT ABLE TO DO ANY SERVLET PROGRAMMING THAT INVOLVES DATABASE CONNECTIVITY...
    THANKS IN ADVANCE

    First of all, don't type everything in uppercase. It is unreadable and impolite (to shout at someone).
    Second, you should not be using the JDBC-ODBC driver for connecting to a Oracle database. There is a pure Java type -4 driver for Oracle available for download. Check the Oracle download page.
    Third, your ojdbc14.jar should NOT be added to common/lib. You should place it in the WEB-INF/lib for the web application. It is not a good idea to mix custom jars with the server libraries.
    Finally, you need to configure a datasource in Tomcat and use that to obtain a connection.
    http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html

  • Using database connection in a servlet and get errors after 8 hours

    Hey,
    I'm running a poker script using applet/servlets and it works great. But for some reason about about 8 hours that database layer stops working. At first I thought it was the connections to mySQL that were timing out (because im using connection pooling) but after turning pooling off (I now create the connection each time) I'm still seeing that same error (I can create a connection but when I do an action ex. like a select statment I get an error). What i'm wondering could it be that the driver I load with Class.forName() some how unloads it's self after x amount of time not being used? Not sure if that is it but if anyone could give me some insight that would be great. The Error i recieve is below:
    INFO: Database Event:DatabaseController: Error executing database query.
    ERROR: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: Software caused connection abort: recv failed
    STACKTRACE:
    java.net.SocketException: Software caused connection abort: recv failed
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(Unknown Source)
         at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:104)
         at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:144)
         at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:172)
         at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1839)
         at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2288)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2784)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2370)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
         at com.mysql.jdbc.Statement.executeQuery(Statement.java:1183)
         at com.softnet.database.DatabaseController.executeDatabaseQuery(DatabaseController.java:190)
         at com.softnet.games.GameServer.validateUser(GameServer.java:438)
         at com.softnet.games.GameServer.handleData(GameServer.java:113)
         at com.softnet.network.HttpConnectionThread.run(HttpServletListener.java:191)
    ** END NESTED EXCEPTION **
    I know the query is good because it works all other times just not after about 8 hours.
    --Z3r0CooL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hey,
    Thanks for the responces. For the connection pooling I would open 5 connections and keep them open. So i though maybe after 8 hours after not being used they would timeout. Thats why i turned off conection pooling and create a new connection each time. Anyways i'll post the code below incase i made a mistake somewhere.
    package com.softnet.database;
    /************************ DatabaseControler **************************/
    import java.sql.*;
    import java.util.*;
    import com.softnet.database.DatabaseConnectionPool;
    import com.softnet.database.DatabaseSettings;
    public class DatabaseController
    implements DatabaseListener
         //Used to make sure the database driver is loaded
         private boolean databaseDriverState = false;
         //Used to store a database connection
         private Connection databaseConnection = null;
         //If to user connection pooling or not
         private boolean useConnectionPooling = false;
         //Used to hold the connection pool varible
         private DatabaseConnectionPool connectionPool = null;
         //Used to store database settings
         private DatabaseSettings databaseSettings;
         //Used to hold the DatabaseController listeners
         private List databaseControllerListeners = new ArrayList();
         //min number of connections for connection pool
         private int minNumberOfConnections = 1;
         //max number of connections for connection pool -1 is unlimited
         private int maxNumberOfConnections = -1;
         //DatabaseController Constructors
         public DatabaseController(DatabaseSettings databaseSettings)
              this.databaseSettings = databaseSettings;
              databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
         public DatabaseController(DatabaseSettings databaseSettings, boolean useConnectionPooling, int minNumberOfConnections, int maxNumberOfConnections)
              this.databaseSettings = databaseSettings;
              this.useConnectionPooling = useConnectionPooling;
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
              if(useConnectionPooling == true)
                   connectionPool = new DatabaseConnectionPool(databaseSettings, minNumberOfConnections, maxNumberOfConnections);
                   connectionPool.addDatabaseListener(this);
              else
                   databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
         public DatabaseController() {}
         //Database Settings Get/Set
         public DatabaseSettings getDatabaseSettings()
              return databaseSettings;
         public void setDatabaseSettings(DatabaseSettings databaseSettings)
              this.databaseSettings = databaseSettings;
         //Connection Pooling Get/Set
         public boolean getConnectionPooling()
              return useConnectionPooling;
         public void setConnectionPooling(boolean useConnectionPooling, int minNumberOfConnections, int maxNumberOfConnections)
              this.useConnectionPooling = useConnectionPooling;
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
              if(useConnectionPooling == true)
                   if(connectionPool == null)
                        connectionPool = new DatabaseConnectionPool(databaseSettings, minNumberOfConnections, maxNumberOfConnections);
                        connectionPool.addDatabaseListener(this);
              else
                   if(connectionPool != null)
                        connectionPool.destroyConnections();
                        connectionPool.removeDatabaseListener(this);
                        connectionPool = null;
         //Return if there connected
         public boolean isConnected()
              boolean isConnected;
              if(databaseConnection != null)
                   isConnected = true;
              else
                   isConnected = false;
              return isConnected;
         //Used to connect to database or get a connection for the connection pool
         public void connect()
              if(databaseDriverState == false)
                   databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
              //If we dont have a current connection, make one
              if(databaseConnection == null && databaseDriverState == true)
                   if(useConnectionPooling == false)
                        try
                             databaseConnection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                        catch (SQLException sqle)
                             //Raise event
                             raiseDatabaseEvent("DatabaseController: Error connecting to database. \nERROR: " + sqle.getMessage());
                             databaseConnection = null;
                   else
                        databaseConnection = connectionPool.getConnection();
         //Used to disconnect from the database or give back the connection to the connection pool
         public void disconnect()
              if(databaseConnection != null)
                   if(useConnectionPooling == false)
                        try
                             //Close DB Connection
                             databaseConnection.close();
                        catch(SQLException ignore) {}
                        finally
                             databaseConnection = null;
                   else
                        connectionPool.returnConnection(databaseConnection);
                        databaseConnection = null;
         public ResultSet executeDatabaseQuery(String sSQL)
              ResultSet databaseResult = null;
              if(databaseConnection != null)
                   try
                        Statement databaseStatement = databaseConnection.createStatement();
                        databaseResult = databaseStatement.executeQuery(sSQL);
                   catch(SQLException sqle)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error executing database query.\nSQL: " + sSQL + "\nERROR: " + sqle.getMessage());
              return databaseResult;
         public int executeDatabaseUpdate(String sSQL)
              int rowsAffected = -1;
              if(databaseConnection != null)
                   try
                        Statement databaseStatement = databaseConnection.createStatement();
                        rowsAffected = databaseStatement.executeUpdate(sSQL);
                   catch(SQLException sqle)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error executing database update.\nSQL: " + sSQL + "\nERROR: " + sqle.getMessage());
              return rowsAffected;
         //Used to load the Database Driver
         private boolean loadDatabaseDriver(String databaseDriver)
              boolean driverLoaded;
              if(databaseDriver.equals("") == false)
                   try
                        //Load Database Driver
                        Class.forName(databaseDriver).newInstance();
                        driverLoaded = true;
                   catch (Exception e)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error loading database driver. \nERROR: " + e.getMessage());
                        driverLoaded = false;
              else
                   driverLoaded = false;
              return driverLoaded;
         //Wrap the DatabaseConnectionPool Error to the DatabaseController
         public void databaseEventOccurred(DatabaseEvent de)
              raiseDatabaseEvent(de.getErrorMessage());
         //Event Handling Code
         //Used to add database listeners (Its sync'd so you can change the listeners when firing an event)
    public synchronized void addDatabaseListener(DatabaseListener databaseControllerListener)
    databaseControllerListeners.add(databaseControllerListener);
    //Used to remove a listener from the list (Its sync'd so you can change the listeners when firing an event)
    public synchronized void removeDatabaseListener(DatabaseListener databaseControllerListener)
    databaseControllerListeners.remove(databaseControllerListener);
    //Used to send the raise event to the listeners
    private synchronized void raiseDatabaseEvent(String databaseError)
    DatabaseEvent databaseEvent = new DatabaseEvent(this, databaseError);
    Iterator listeners = databaseControllerListeners.iterator();
    while(listeners.hasNext())
         DatabaseListener listener = (DatabaseListener) listeners.next();
    listener.databaseEventOccurred(databaseEvent);
    /********************* DatabaseConnectionPool **************/
    package com.softnet.database;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import com.softnet.database.*;
    import com.softnet.database.DatabaseSettings;
    public class DatabaseConnectionPool
         //min number of connections
         private int minNumberOfConnections = 1;
         //max number of connections -1 is unlimited
         private int maxNumberOfConnections = -1;
         //Store the connections
         protected Hashtable databaseConnections = null;
         //Database Info
         protected DatabaseSettings databaseSettings;
         //to hold Driver state
         private boolean databaseDriverState = false;
         //To hold connection checker
         private DatabaseConnectionCheck connectionChecker = null;
         //Used to hold the DatabaseConnectionPool listeners
         private List databaseConnectionPoolListeners = new ArrayList();
         public DatabaseConnectionPool(DatabaseSettings databaseSettings, int minNumberOfConnections, int maxNumberOfConnections)
              this.databaseSettings = databaseSettings;
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
              //Load Driver
              databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
              //Create connection
              createConnections();
         public DatabaseConnectionPool(int minNumberOfConnections, int maxNumberOfConnections)
              this.minNumberOfConnections = minNumberOfConnections;
              this.maxNumberOfConnections = maxNumberOfConnections;
         //Database Settings Get/Set
         public DatabaseSettings getDatabaseSettings()
              return databaseSettings;
         public void setDatabaseSettings(DatabaseSettings databaseSettings)
              this.databaseSettings = databaseSettings;
         //Driver State Get
         public boolean getDatabaseDriverState()
              return databaseDriverState;
         public void createConnections()
              if(databaseDriverState == false)
                   databaseDriverState = loadDatabaseDriver(databaseSettings.getDatabaseDriver());
              //Create all connections and load the minimum in the Hashtable
              if(databaseConnections == null)
                   if(databaseDriverState == true && minNumberOfConnections != 0)
                        databaseConnections = new Hashtable();
                        for(int i = 0; i < minNumberOfConnections; i++)
                             try
                                  databaseConnections.put(DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword()), Boolean.FALSE);
                             catch(SQLException sqle)
                                  //Problem break loop and destroy any connections
                                  destroyConnections();
                                  //Raise event
                                  raiseDatabaseEvent("DatabaseConnectionPool: Error creating database connections. \nERROR: " + sqle.getMessage());
                                  break;
              //If no connection check exists create one
              if(connectionChecker == null)
                   connectionChecker = new DatabaseConnectionCheck(this);
                   connectionChecker.start();
         public Connection getConnection()
              Connection connection = null;
              boolean errorWithConnection = false;
              Enumeration connections = databaseConnections.keys();
              synchronized (databaseConnections)
                   while(connections.hasMoreElements())
                        errorWithConnection = false;
                        connection = (Connection) connections.nextElement();
                        Boolean state = (Boolean) databaseConnections.get(connection);
                        //If connection is not used, use it.
                        if(state == Boolean.FALSE)
                             try
                                  connection.setAutoCommit(true);
                             catch(SQLException e)
                                  //Problem with connection remove connection and replace it
                                  databaseConnections.remove(connection);
                                  try
                                       connection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                                  catch(SQLException sqle)
                                       errorWithConnection = true;
                             if(errorWithConnection == false)
                                  // Update the Hashtable to show this one's taken
                                  databaseConnections.put(connection, Boolean.TRUE);
                                  // Return the connection
                                  return connection;
                   //All connections being used check to max to see if we can make a new one
                   if(maxNumberOfConnections == -1 || maxNumberOfConnections > databaseConnections.size())
                        try
                             connection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                        catch(SQLException sqle)
                             errorWithConnection = true;
                        if(errorWithConnection == false)
                             databaseConnections.put(connection, Boolean.TRUE);
                             return connection;
              //If not connections free and max connections reached wait for a free connection
              return getConnection();
         public void returnConnection(Connection connection)
              boolean errorWithConnection = false;
              //Make sure connection still works
              try
                   connection.setAutoCommit(true);
              catch(SQLException e)
                   //Problem with connection remove connection and replace it
                   databaseConnections.remove(connection);
                   try
                        connection = DriverManager.getConnection(databaseSettings.getDatabaseURL(), databaseSettings.getUserName(), databaseSettings.getUserPassword());
                   catch(SQLException sqle)
                        errorWithConnection = true;     
              if(errorWithConnection == false)
                   databaseConnections.put(connection, Boolean.FALSE);
         public void destroyConnections()
              Connection connection = null;
              if(databaseConnections != null)
                   //Close all connections
                   Enumeration connections = databaseConnections.keys();
                   while (connections.hasMoreElements())
                        connection = (Connection) connections.nextElement();
                        try
                             connection.close();
                        catch(SQLException ignore) {}
                   //Free up hashtable
                   databaseConnections = null;
         private boolean loadDatabaseDriver(String databaseDriver)
              boolean driverLoaded;
              if(databaseDriver.equals("") == false)
                   try
                        //Load Database Driver
                        Class.forName(databaseDriver);
                        driverLoaded = true;
                   catch (ClassNotFoundException cnfe)
                        //Raise event
                        raiseDatabaseEvent("DatabaseController: Error loading database driver. \nERROR: " + cnfe.getMessage());
                        driverLoaded = false;
              else
                   driverLoaded = false;
              return driverLoaded;
         //Event Handling Code
         //Used to add database listeners (Its sync'd so you can change the listeners when firing an event)
    public synchronized void addDatabaseListener(DatabaseListener databaseConnectionPoolListener)
    databaseConnectionPoolListeners.add(databaseConnectionPoolListener);
    //Used to remove a listener from the list (Its sync'd so you can change the listeners when firing an event)
    public synchronized void removeDatabaseListener(DatabaseListener databaseConnectionPoolListener)
    databaseConnectionPoolListeners.remove(databaseConnectionPoolListener);
    //Used to send the raise event to the listeners
    private synchronized void raiseDatabaseEvent(String databaseError)
    DatabaseEvent databaseEvent = new DatabaseEvent(this, databaseError);
    Iterator listeners = databaseConnectionPoolListeners.iterator();
    while(listeners.hasNext())
         DatabaseListener listener = (DatabaseListener) listeners.next();
    listener.databaseEventOccurred(databaseEvent);
    class DatabaseConnectionCheck extends Thread
         private DatabaseConnectionPool connectionPool;
         DatabaseConnectionCheck(DatabaseConnectionPool connectionPool)
              this.connectionPool = connectionPool;
         public void run()
              try
                   while(true)
                        //check threads every 30 seconds
                        this.sleep(300000);
                        if(connectionPool.databaseConnections != null)
                             Connection connection = null;
                             Enumeration connections = connectionPool.databaseConnections.keys();
                             synchronized (connectionPool.databaseConnections)
                                  while(connections.hasMoreElements())
                                       connection = (Connection) connections.nextElement();
                                       Boolean state = (Boolean) connectionPool.databaseConnections.get(connection);
                                       //If connection is not used, use it.
                                       if(state == Boolean.FALSE)
                                            try
                                                 connection.setAutoCommit(true);
                                            catch(SQLException e)
                                                 //Problem with connection remove connection and replace it
                                                 connectionPool.databaseConnections.remove(connection);
                                                 try
                                                      connection = DriverManager.getConnection(connectionPool.databaseSettings.getDatabaseURL(), connectionPool.databaseSettings.getUserName(), connectionPool.databaseSettings.getUserPassword());
                                                 catch(SQLException sqle)
                                                      connection = null;
                                                 // Update the Hashtable with new connection if its not null
                                                 if(connection != null)
                                                      connectionPool.databaseConnections.put(connection, Boolean.FALSE);
              catch(InterruptedException ignored) {}     
    Basicly the why it works is the connection pool hold the database connections. When the user needs a connection they use the database controller to request a connection (By create a instance and called the connect() method) and the connection is either created or grabed from the connection pool. After the user is done with the connection they call the disconnect() method which closes the connection or returns it to the connection pool.
    --Z3r0CooL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

  • Help with Database Connected LiveCycle ES4 form

    Hello and thanks for taking the time to read this question, I hope you can help!
    I have a LiveCycle ES 4 form connected to an excel database.  The form has buttons to "Add", "Update" or "Find" a record.  These buttons all work correctly EXCEPT when the server drive that has the Excel file is not available.  In this case I wanted to add code the "Add" button informing the user that there is an error.  I tried adding a try/catch block before the SQL statement that inserts a record into excel but even when I purposely make the Excel file unavailable the try/catch block doesn't seem to work.  The javascript console will show an error but try/catch doesn't seem to trigger.  If I had a javascript syntax error within the try/catch block, it works as expected, but with the database connected form, it appears the try/catch block does not trigger based on errors generated as a result of the database file having an issue.  In this case, the console just shows a "GeneralError: Operation failed." message.  Why doesn't the try/catch block trigger since there is an error as stated on the console?  Is there a work around?  Thanks again for your help!!

    Hello and thanks for taking the time to read this question, I hope you can help!
    I have a LiveCycle ES 4 form connected to an excel database.  The form has buttons to "Add", "Update" or "Find" a record.  These buttons all work correctly EXCEPT when the server drive that has the Excel file is not available.  In this case I wanted to add code the "Add" button informing the user that there is an error.  I tried adding a try/catch block before the SQL statement that inserts a record into excel but even when I purposely make the Excel file unavailable the try/catch block doesn't seem to work.  The javascript console will show an error but try/catch doesn't seem to trigger.  If I had a javascript syntax error within the try/catch block, it works as expected, but with the database connected form, it appears the try/catch block does not trigger based on errors generated as a result of the database file having an issue.  In this case, the console just shows a "GeneralError: Operation failed." message.  Why doesn't the try/catch block trigger since there is an error as stated on the console?  Is there a work around?  Thanks again for your help!!

  • HELP----Inactive database connections.

    I have just deployed a JDeveloper BC4J application and to my surprise, when a user enters a module, the database connections are all Inactive in the database. All my users have their own user ids. I am using Jdeveloper 9.0.3.4 (build 1247) and 10gAS on the middle tier. After running debug options, I can't see where the connection is being closed. Has anyone experienced this? I have logged a TAR and after 4 days, support is getting nowhere.
    Brett

    hi
    did you get an answer?
    if so could you post it?
    thanks
    Vitor

  • Please help with database connection issue

    Hi,
    I've created a few connections and pages with a few recodsets on my local computer and am connecting fine with the database. I've uploaded the database via phpmyadmin onto a remote server and uploaded all my pages to the website and have changed the database info, user name and password in the connections folder but when I try to load the file I get a message "no database selected". I've tried various things but no luck. I'm selecting the database name but something is missing. Any help would be appreciated.
    Derek

    A bit more info: Here is the connection script as its defined in Dreamweaver: <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_karen_product = "localhost";
    $database_karen_product = "karen";
    $username_karen_product = "root";
    $password_karen_product = "root";
    $karen_product = mysql_pconnect($hostname_karen_product, $username_karen_product, $password_karen_product) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    Where is says mysql_pconnect, I changed the $hostname_karen_product etc to 'localhost', 'username', 'the password for the database')
    Do i need to do something different at $database_karen_product?
    I'm basically new at this and confused as to how to alter this connection script.
    Thanks
    Derek

  • Help with database connection

    ok I am trying to use dreamweaver's database function to
    connect to a mysql database, i fill in the info and it gives me the
    following error:
    "an unidentified error has occurred"
    I know all the info i am putting in is correct as I am copy
    and pasting it directly out of my connection properties in navicat
    mysql editor which can connect to the database fine
    i tried connecting to multiple databases on multiple servers
    and every single one returned the exact same error
    I am using Dreamweaver CS3 for Mac OSx
    thx for any help
    -Ryan

    Have you gone under the Application folder and clicked on the
    plus (+) sign and created the connection to the database.
    Also, do you have username and password on the database? If
    so, you'll have to provide this information
    I don't use MAC or PHP a great deal. So my help can be rather
    limited. I'm just thinking about connection strings
    What web server are you using? MAke sure it's running and set
    up correctly. Test the server first and see if it's working. If so
    see what connections string Dreamweaver is providing. I know Apache
    had a few bugs with various version just Windows has had in the
    past, not sure how these work with OSX

  • [Help] Regarding database connection!

    Hi , i am new to dreamweaver, I have started working on a website, the designing part is completed. I am now trying to connect database through dreamweaver to mysql. As i said I am new to this, I have created four pages, all of which are in .html format. When i  try to connect to a database, it needs me o choose from .php or dotnet.
    So, here is my question do I need to shift my work to dotnet or php? As i dont know php so i am taking dotnet
    2ndly how can I connect to a database? All schemas are defined! Which files do i need to change if i want a registration page to connect to database??
    Please Help!

    If you want to connect your website to a database, it's advisable to change the filename extension of all pages from .html to the server-side technology of your choice. Before making your choice, you might find the following article helpful: Which server-side technology should I choose?
    If you decide on .NET, you should be aware that Dreamweaver has no support for it.
    Dreamweaver has extensive support for PHP, but I wouldn't recommend using Dreamweaver's built-in server behaviors to connect to a database. They rely on outdated code, and are not recommended for use in a live website.
    If you want to set up Dreamweaver to work with PHP, instructions for doing so are in the following article: http://www.adobe.com/devnet/dreamweaver/articles/setup_php.html.

  • Need help regarding database connection

    hello
    iam new to j2ee i am using Jsp,Ejb and Jboss server i need to connect to the oracle database with the above configuration wher can i find the tutorials can anybody help me please

    a word of advice - if you're new to jsp, jboss, and ejbs, and obviously know nothing about jdbc either, this isn't the way to learn it.
    start with the jdbc tutorial and see if you can get a single java class to connect to a database and execute some sql. then work up from there.
    what you're doing is something known as "biting off more than you can chew".
    %

  • Problems with Database connection from a servlet

    Hi everybody:
    I got the following message:
    java.lang.ClassNotFoundException: weblogic/jdbc/oci/Driver
    when I try to connect to a Database.
    public Connection getConnection()
    Connection con = null;
    Driver myDriver = null;
    try
    Properties props = new Properties();
    props.put("user", "fangc");
    props.put("password", "fangc");
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    con = myDriver.connect("jdbc:weblogic:oracle:occd01", props);
    catch(Exception e)
    System.out.println("Connection failed! - " e);
    finally
    return con;
    What am I doing wrong? I try the code without problem for a simple Java Client

    Cristina Fang wrote:
    >
    Hi everybody:
    I got the following message:
    java.lang.ClassNotFoundException: weblogic/jdbc/oci/DriverYou won't get that unless your code has:
    myDriver = (Driver) Class.forName("weblogic/jdbc/oci/Driver").newInstance();
    Make sure your servlet code is just like the right way that you have it
    below:
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    Joe
    >
    when I try to connect to a Database.
    public Connection getConnection()
    Connection con = null;
    Driver myDriver = null;
    try
    Properties props = new Properties();
    props.put("user", "fangc");
    props.put("password", "fangc");
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    con = myDriver.connect("jdbc:weblogic:oracle:occd01", props);
    catch(Exception e)
    System.out.println("Connection failed! - " e);
    finally
    return con;
    What am I doing wrong? I try the code without problem for a simple Java Client

  • Please Help! Database connection

    Hey guys,
    I know this may seen very simple to some of you and I hope
    that you can help me with all of your knowledge. I am trying to set
    up a database for the first time. I just want to have a login page
    on my site and I have no idea how to get started. I pretty much
    need step by step instructions if someone could help. So far my
    hosting provider told me some things but I still get an error
    message. I was told the best way to connect to a ms sql database is
    through a connection string. I tried that and it told me that my
    name could not have any " - " in it. Then I tried getting rid of it
    and it keeps giving me errors. If someone could please just point
    me in the right direction to get started with this then I would be
    forever greatful. Thank you so much for any help you can give me.
    Jeremy

    here is a example of a connection string
    "Driver={Microsoft Access Driver (*.mdb)};
    DBQ=D:\Webmolder\ajack\training\db\assessment.mdb"

  • Need help with database connection and trasaction!

    Hi, I'm trying to load data from a huge report to DB2. My old way of doing this is: 1. using DriverManger.getConnection to get a connection.
    2. Then set autoCommit to false.
    3. Keep the connection open.....
    4. con.commit once I reach a section, let's say around 5000 records per section.
    5. Close the connection once I finish loading, (Finally block)
    I'm still new in the java world and kind of concern of the way of what I'm doing. Then I did some research. Perhaps using javax.sql.DataSource is a better approach. But I couldn't use it in WSAD. Do I need do some configuration? I heard it's in j2ee 1.4 . Is that the reason I couldn't use it?
    And.......I tried to use DAO pattern to talk with DB. By that way, I have to open and close connection everytime I invoke the dao method. Then how can I control the transaction? Because I don't want to insert each record data in to the table right away. I want to do the commit once I get all records for one section. No idea how can I achieve this.
    Any suggestion will be really appreciated!!!

    I'm still new in the java world and kind of concern
    of the way of what I'm doing. Then I did some
    research. Perhaps using javax.sql.DataSource is a
    better approach. But I couldn't use it in WSAD. Do I
    need do some configuration? I heard it's in j2ee 1.4
    . Is that the reason I couldn't use it?What you need to do is configure a Connection datasource. WSAD has that. You just need to go through the documentation and find out. I never worked on it.
    And.......I tried to use DAO pattern to talk with DB.
    By that way, I have to open and close connection
    everytime I invoke the dao method. Then how can I
    control the transaction? Because I don't want to
    insert each record data in to the table right away. I
    want to do the commit once I get all records for one
    section. No idea how can I achieve this.Since you want to simply insert multiple records, you might want to insert them in a batch. This is available in PreparedStatements.
    $ Carol.

  • Need Help with Database Connection

    Hello,
    i have the order to create a Dynamic pfd with Adobe Live Cycle Designer which takes some source information from a Microsoft Access Database.
    I am absolutely new in Adobe Live Cycle Designer, but I have experiences in VBA, C++ and Delphi...
    Thanks for Help

    Ok, got it...

  • Share database connection between servlets

    hello,
    i need help to know if the following code works well.
    The intention is to share a unique JDBC database connection with all servlets of my application.
    //************************ file Conexao.java ***********************
    // this class makes a databse connection
    import java.sql.*;
    public class Conexao
    Connection conex;
    public void conecta()
    try
    Class.forName("interbase.interclient.Driver");
    conex = DriverManager.getConnection("jdbc:interbase://localhost/c:\\temp\\Kuala.gdb","SYSDBA","masterkey");
    catch(ClassNotFoundException ex) { }
    catch(SQLException ex) { }
    public void desconecta()
    try
    { conex.close(); }
    catch(SQLException ex) { }
    //****************** file SetConnectionContext ****************
    // this class creates an instance of Conexao class and invokes the
    // conecta() method. After, obtain the ServletContext object and
    // set the attribute "conecta" to the ServletContext
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class SetConnectionContext extends HttpServlet
    Conexao connection = null;
    public void init()
    connection = new Conexao();
    connection.conecta();
    ServletContext context = getServletContext();
    context.setAttribute("conecta", connection);
    public void destroy()
    { connection.desconecta(); }
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    response.setContentType("text/html");
    PrintWriter saida = response.getWriter();
    saida.println("<H1>objeto connection atribuido no contexto</H1>");
    //****************** file GetConnectionContext.java ******************
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class GetConnectionContext extends HttpServlet
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    response.setContentType("text/html");
    PrintWriter saida = response.getWriter();
    ServletContext context = getServletContext();
    Conexao con = (Conexao) context.getAttribute("conecta");
    try {
    Statement comando = con.conex.createStatement();
    ResultSet rs = comando.executeQuery("SELECT * FROM kl_campanha");
    while( rs.next() )
    int codCampanha = rs.getInt("codCampanha");
    saida.println("<h3>"+codCampanha+"</h3>");
    catch(Exception e) { }

    I understand the use of a static variable.
    But if i want to share a database connection object (a
    instance varible instead of class variable) that is
    instantiate once and saved in a ServletContext
    attribute,
    and afterwards the other servlets can get
    the object through the ServletContext attribute and
    use it. This will works well? i did tests with the
    code and everything apparently works.
    How does a new connection (different user) get the old context?

Maybe you are looking for

  • Why do I get an error message that says "Incompatible Types"?

    I am a newbie to Java programming. I have experience with VB. I am using Net Beans 6.1. I was following a sample program that shows me how to use the JDBC ODBC bridge to connect to an MS-Access file. I get an error message at this line: statement = c

  • How to know exact size of table with blob column

    I have a table with one BLOB column. I ran this query. select bytes/1024/1024 from user_segments where segment_name='GMSSP_REQUEST_TEMP_FILES' (user_segments is a view) it gave me 0.125 It means size of table is 0.125. I have uploaded 3 files to this

  • JPopupMenu with JInternalFrame, popup menu doesn't work

    hi, i have this problem, as shown in the sample code at the end of this post.. basically, i have a table, and i added a JPopupMenu onto the table.. the popup menu works well when running the table class, though, when i call the table class in a JInte

  • No WiFi after IOS 7.1 update

    This morning I updated my iPhone 5 to 7.1 and can no longer connect to ANY wifi.  I have restored the phone to original settings as instructed when connecting to iTunes, checked my home wifi password 100x's, restarted phone, tried switching to Airpla

  • What exactly does the MasterPageFile="~masterurl/default.master" in the page mean?

    Hi Everyone, I want to create a site definition that use my own master page in the homepage (VS2012 + SP2010). When the site definition is created, there are already codes in the default.aspx page that simply display a string in the body. And the pag