Single database connection create and using  all programs jsp and servlet

Hai
i am create databaset connection using that all programs how to implement

Post the steps you managed already. If you don't know anything about how to receive data from a database try this link:
http://java.sun.com/docs/books/tutorial/jdbc/index.html

Similar Messages

  • Can i use single database connection in a hole java application?

    can i use single database connection in a hole java application?.I have so many forms to use database connection.

    Theoretically you can. Not only theoretically. I've seen lots of application which only uses one database connection (they were using, oracle or mysql)
    The first reply given here assumed that the answer to
    your question depends only on the design of your
    application. That is not true.Yes it's true. Nothing in the original questions says that you aren't allowed to open or close the single connection that you have. It's looks more like the OP is interested in sharing a connection (i.e having a singleton or a connection pool with only one connection)
    It does also depend on the behaviour of the database
    in the background.
    Most databases have a time out for connections that
    are idle Not a problem. Most implementations of connection pools and applications which keeps a connection open have a timer which calls e.g. select * from dual (if you are using oracle) when the connection has been idle for X minutes.
    (some, like db2 on z/OS, even cancel
    connections, that are not idle, if they are open a
    certain amount of time or have reached a given limit
    of cpu seconds.)You would also have that problem if you had a connection pool with several connections.
    In essence: If you have no control over the time
    your application runs (and therefore your connection
    is open) or over type or the configuration of the
    database you are accessing, you can't do it.See above.
    The closest thing to what you want would be using
    PooledConnections, iif those are supported for the
    database you want to access.Not true.
    Kaj

  • How to use a single page for create and update mode.

    Hi,
    I need to develop a single page to be used for both create and update modes.
    I am going to use a variable MODE
    and i will set this in the emp summary page.
    Based on the button clicked by the user i have to render the JSF page.
    For tis if the user selects a perticular and cliks on update thn i will pass the empno to the next.
    so there in the next i will appy a ViewCreiteria on my View Obj to fetch only that row so that only that emp will be displayed ion update mode.
    This is working fione for me.
    So now the issue is
    when the user clicks on CreatEmp button.
    i need to enable my VO for insert operations.
    for this i wrote the code like this in the beforePhase event
    FacesContext ctx = FacesContext.getCurrentInstance();
    ValueBinding valBinding = ctx.getApplication().createValueBinding("#{data}");
    BindingContext bContext = (BindingContext) valBinding.getValue(ctx);
    DCDataControl dcControl = bContext.findDataControl("DataControl");
    Application app = ctx.getApplication();
    ApplicationModule am = (ApplicationModule) dcControl.getDataProvider();
    System.out.println("After Appmodule initiation");
    // get the VO reference and initiate the query
    System.out.println("Before Page VO initiation");
    PrismDmPageSectionViewImpl vo = (ViewImpl)am.findViewObject("View");
    //ViewRowImpl row = (ViewRowImpl) vo.createRow();
    /* TO CREATE AN EMPTY ROW*/
    Row row=vo.createRow();
    System.out.println("New Row is created");
    //vo.createKey(row);
    vo.insertRow(row);
    vo.setCurrentRow(row);
    By doing this a new empty page is rendered.
    But when i fill up the values and click on ok.. i am getting the error like this..
    JBO-27023: Failed to validate all rows in a transaction.
    JBO-27027: Missing mandatory attributes for a row with key null of type View3
    JBO-27014: Attribute Id in View3 is required
    JBO-27014: Attribute PageeId in View3 is required
    Please point me out where i am missing.
    Thanks

    Hi,
    In my opinion you are over complicating things.
    This is what I do for using the sme page as both create and update without all this code.
    1) Create a browse page containing a an adf table with a select one component bound to your view object.
    2) Create an additional edit page containing only an edit form containing fields of your view object that your users must enter in order to add or edit rows.
    3) Link the pages in the JSF diagram with an "edit" navigation case from browse to edit page and a "return" navigation case from edit to browse (make sure that redirect option is NOT set on both cases)
    4) Remove the submit button from the edit page and add two application module bindings for the commit and rollback operations as command buttons in the form footer facet. Make sure that both buttons has an action of return and that their disabled property is set to false. You will probably change their labels to ok and cancel respectively.
    5) Drop a create action for your view object from the data control palette inside your page as a command button and set the action property to edit also.
    3) Set the action property of the view button to edit
    This should basically work without any code from your part. -- at least it does so for me -- if you like to make it a bit more funcy you may add am action listener inside your buttons and set a requeScope variable for example #{requestScope.editing} to true or false depending on the button clicked. Then add a title to your page with a value like #{requestScope.editing == true ? 'Editing record' : 'Adding a new record'}..
    Hope that helps.
    Thanassis

  • Parallel database connection​s and single query between databases

    Hi, I am looking to execute this SQL query between 2 different databases to update a local database based on data selected from a remote one.
    e.g.:
    - Local database name: db1
    - local database schema: dbo
    - local database table1
    - remote database name: db2
    - remote database schema: dbo
    - Remote database table: table2
    - Query: "SELECT * FROM db2.dbo.table2 WHERE NOT EXISTS(SELECT * FROM db1.dbo.table1)" <- This gets e the record set i would need to insert, and I already have a vi to do that kinda thing.
    How do I go about this?
    Thanks,
    Mohamed

    Mohamed,
    There is a VI in the Database Connectivity Toolkit that allows you to execute SQL queries:  DB Tools Execute Query.
    http://zone.ni.com/reference/en-XX/help/370016E-01​/lvdatabase/db_tools_execute_query/
    Is this what you are looking for?
    Drew T.
    NIC AE Specialist

  • Listener EA2: database connection pool and connection revalidation

    Hi all,
    As one can expect from early adopter release there could be some bugs but I can't find any references in forum to my situation:
    * My 11g XE database and listener are starting as windows services when server boots operating system (Windows Server 2003 R2).
    * I configured my web server (unsupported Jetty 9.0.0.M1) to start as windows service when operating system starts.
    * Apex Listener 2.0.0.268.17.05 configured to connect with XE using JDBC thin driver with default settings (initial pool size 3, max statements 10, min connections 1, max connections 10, inactivity timeout 1800, abandoned connection timeout 900)
    * Because web server starts a bit faster than Oracle database when apex connects first time it gets "ORA-12528, TNS:listener: all appropriate instances are blocking new connections" (could be that database still starting but already registered service with listener)
    * From listener.log file I can see that all further connections made from Apex listener succeeds
    * When I try to open any apex page with browser I am getting 404 error and apex listener logs error (*time is 2 days after system startup*):
    2012-11-30 3:56:02 PM oracle.dbtools.common.config.db.DatabaseConfig badConfiguration
    SEVERE: The pool named: apex is not correctly configured, error: Listener refused the connection with the following error:
    ORA-12528, TNS:listener: all appropriate instances are blocking new connections
    ConnectionPoolException [error=BAD_CONFIGURATION]
         at oracle.dbtools.common.jdbc.ConnectionPoolException.badConfiguration(ConnectionPoolException.java:62)
         at oracle.dbtools.common.config.db.DatabaseConfig.badConfiguration(DatabaseConfig.java:146)
         at oracle.dbtools.common.config.db.DatabaseConfig.createPool(DatabaseConfig.java:168)
         at oracle.dbtools.common.config.db.DatabaseConfig.getConnection(DatabaseConfig.java:68)
         at oracle.dbtools.common.jdbc.ora.OraPrincipal.connection(OraPrincipal.java:25)
         at oracle.dbtools.apex.ModApexContext.getConnection(ModApexContext.java:320)
         at oracle.dbtools.apex.Procedure.getProcedure(Procedure.java:166)
         at oracle.dbtools.apex.OWA.validateProcedure(OWA.java:384)
         at oracle.dbtools.apex.security.Security.isValidRequest(Security.java:171)
         at oracle.dbtools.apex.ModApex.validateRequest(ModApex.java:233)
         at oracle.dbtools.apex.ModApex.doGet(ModApex.java:79)
         at oracle.dbtools.apex.ModApex.service(ModApex.java:263)
         at oracle.dbtools.rt.web.HttpEndpointBase.modApex(HttpEndpointBase.java:288)
         at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:127)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
         at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:665)
         <... Jetty web server stack ...>
         at java.lang.Thread.run(Unknown Source)
    2012-11-30 3:56:02 PM oracle.dbtools.rt.web.HttpEndpointBase modApex
    * Oracle listener log for same time (no errors here):
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1078)) * establish * xe * 0
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1079)) * establish * xe * 0
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1080)) * establish * xe * 0
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1081)) * establish * xe * 0
    * For some reason apex listener keeps first connection status and won't try to establish new connection if first attempt finished with ORA-12528
    * The same scenario is valid when at time of web server start oracle database/listener is not available - even if database and listener starts and apex successfully establishes further connections all apex pages gets 404 error
    * If I restart web server windows service (while oracle db and listener still running) browser opens apex pages without errors and apex listener does not log any errors
    * I know that I can avoid this error delaying start of web server windows service but it would be nice to have production release 2.x without such bugs

    Hi,
    Is there any way to use the connection pool or Datasource while connecting to database?If I am using a stateless sesssion bean and using a Data Access layer which just creates a database session to write the persistence toplink objects how I can make use of application server connection pool?Hi Vinod,
    Yes, TopLink allows you to use the app server's connection pooling and transaction services. Chapter 2 of the Oracle9iAS TopLink Foundation Library Guide provides details as do the TopLink examples. The easiest way to set this up is by using the sessions.xml file. The sample XML below is from the file <toplink903>\examples\ias\examples\ejb\sessionbean\sessions.xml. Here we are adding the datasource defined in OC4J and specifying that we are using the OC4J transaction controller also.
    <login>
    <user-name>sa</user-name>
    <password></password>
    <datasource>java:comp/env/jdbc/ejbJTSDataSource</datasource>
    <uses-external-transaction-controller>true</uses-external-transaction-controller>
    <uses-external-connection-pool>true</uses-external-connection-pool>
    </login>
    <external-transaction-controller-class>oracle.toplink.jts.oracle9i.Oracle9iJTSExternalTransactionController</external-transaction-controller-class>
    When using this approach you need to change your TopLink code slightly in the EJB methods:
    a. Acquire the ACTIVE unit of work from the server
    session (again, see the EmployeeSessionEJB code
    example) with something like:
    UnitOfWork uow = clientSession.getActiveUnitOfWork();
    b. Calls to uow.commit() can be ommitted or commented out
    because the EJB will handle this. Note that of course
    the methods you create in the EJB that are using this
    approach must have TX Required (default).
    Hope this helps.
    Pete

  • Labview Database Connection Toolkit and decimal point

    Hi,
    on my system I use "," (comma) as decimal point.
    In Labview Options I unflagged "Use localized decimal point", and numeric controls and indicators use "." (dot) as decimal point.
    The problem is that Labview Database Connection Toolkit keeps returning floating point numbers as strings with comma as decimal point.
    Has anyone experienced this issue?
    Is this related to Labview or MySQL ODBC Connector (that I'm using to connect to a mySQL DB)?
    Thanks in advance for any help,
    Marco

    You have two or three places to look. First there is the DCT. Second, there's a couple layers there that could cause problems (the mySQL drivers and ADO) and then there's even the posibility that the issue could be in the DBMS itself.
    I would start by burrowing down through all the DCT layers and find the spot where the results are actually being read back fromt he database. If the resutls are read as variants and converted to LV datatypes, the problem is on the LV side. If the values are being read as strings and converted, the problem coiuld be on the other side.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Database connectivity toolset and nested transaction

    Is it possible to make nested transactions with the Database Connectivity Toolset ?
    By nested transactions I mean that I want to open a transaction inside a transaction.
    I use LabVIEW 6.1 and Database Connectivity Toolset 1.1
    Any ideas are welcome.

    You may be able to do this in a different manner. Your options depend on how the database has structured the data. For example you can have a table defining "measures", another table defining "measure setps" and so on.
    Each measure has an ID (MID) and each measure step has an ID (MSID) and these can be related to each other to provide the hierarchy. So in this case you could just get a measure, then query for all the measure steps that match (the MID and MSID) and sort them based on some attribute/criteria and work down in that manner.
    This would provide a clean data architecture and enable you to reuse steps in multiple measures if you needed to. I'm not sure how your database is building the hierarchy, in the end there are some parent ch
    ild relationships defined ... these would be very similar to the IDs referred to above.
    Like you said, had to explain without a picture.
    Regards,
    Kamran

  • How can different user on one PC use all programs

    I have two user on one PC and it should be possible that all user can use all programms.
    Is it possible?
    What do I have to do?

    Mac OS X is inherently a Multi-User system, even if you were to create only one User account on it.
    Mac OS X maintains completely separate System Files, protected from most arbitrary access, and Applications and Utilities are stored there to be used by all users.
    Changeable information, including Preferences that seem to be system-wide, are actually stored in User directories under:
    /Users/your username/
    To have multiple Users run the same programs with different settings, you must do the following:
    • Nothing.
    Your Mac is already set up to do exactly that.
    EDIT: Allan Eckert types faster than I do, and brings up an important point.
    The Applications included with Mac OS X and installed automatically are placed in:
    /Applications and
    /Applications/Utilities
    and are available to all Users.
    If you Install an Application in a User directory, it will only be available to that user.
    So don't do that!
    Install Applications in the standard places, which WILL require that you provide an Administrator Username and Password.

  • ALI Database Connection Configuration and Monitoring

    Is there some way -- documented or not -- to set the number of connections that ALI uses between it and the SQL Server or Oracle instance behind it? If so, what's the default setting (and how do you override it)?
    Also, can we somehow monitor the number of active connections that ALI has to the database?
    Thanks!
    Chris Bucchere | bdg | [email protected] | http://www.thebdgway.com

    Chris,
    I thought a lot of this was covered in a previous post -
    [url http://forums.bea.com/bea/message.jspa?messageID=400007669&tstart=0]http://forums.bea.com/bea/message.jspa?messageID=400007669&tstart=0
    The maximum # of DB connections can be set in a config file. The portal itself control the actual number of connections between the min & max in its OpenDB connection pooling logic. I believe the default max # of connections is 40 connections.
    I believe the "Counter Monitoring System" - described in the G6 Administration Guide - provide a means to monitor the number of DB connections although I believe the same info could be obtained through other means at the OS-level.
    John
    Is there some way -- documented or not -- to set the
    number of connections that ALI uses between it and
    the SQL Server or Oracle instance behind it? If so,
    what's the default setting (and how do you override
    it)?
    Also, can we somehow monitor the number of active
    connections that ALI has to the database?
    Thanks!
    Chris Bucchere | bdg | [email protected] |
    http://www.thebdgway.com

  • Single database connection/detecting disconnect

    I receive an error when attempting to connect to the database after the database had gone down and was subsequently brought back up. The code checks to see if the connection 'isClosed' but this method seems to fail under these circumstances. The solution is to re-start the Apache server and log on. Is there a fix to prevent the error message? The connection is created by the first person to login and is maintained through subsequent database requests.
    Below is code to test for an existing connection......
    public Stuff[] getStuff() throws DBException {
    try { synchronized(dbConn) {
    if(dbConn.isClosed()) { this.dbInit(); }
    //etc,etc,etc
    Below is code for dbInit method.......
    private void dbInit()     throws DBException {
    String getStuff="SELECT * from tbl WHERE uname = ?";
    try {
    Class.forName(driverName);     
    dbConn = DriverManager.getConnectio(dUrl,user,pass);
    getUserStmt = dbConn.prepareStatement(getStuff);
    catch (ClassNotFoundException     exc) {     
    throw new DBException("No Driver Available!")}
    catch     (SQLException exc) {
    throw new DBException(exc.getMessage());}

    Depending on what DB platform and driver version you're running on I think your best bet is to have Apache create a DB connection pool and have your app pull from the pool. That way Apache always creates the pool on startup and checks the state of connections periodically. Unless you reach the maximum number of connections allowed by security or DB platform you should always have a connection.

  • Bootcamp NON intel CPU's-use all programs

    Does Bootcamp Support NON intel CPU's like my G4 IMAC? and Can it use ALL of the windows programs?

    http://www.apple.com/support/bootcamp/
    Only Intel when talking Macs, no PowerMacs or G4 etc.

  • Database connectivity toolset and microsoft access

    Bonjour,
    je suis débutante labview et j'aurais besoin d'aide...
    voici mon pb:
    j'ai créé une table sous microsoft access et j'aimerais lire les données à partir de labview en utilisant "database connectivity toolset". les vi utilisés sontpen connection, select data et close connection.
    le vi "open connection" demande le 'connection information': j'ai donc donné le chemin ou se trouve mon fichier .udl
    ce fichier udl est configuré comme cela:
    fournisseur: microsoft jet et connexion: le chemin ou se trouve le fichier access.
    mais ca ne marche pas! j'ai une erreur apres le vi select data, qui me dit 'erreur syntax'
    je ne sais pas si j'utilise les bons vi....
    merci pour une réponse rapide.

    Bonjour,
    Tout d'abord, vous devez vérifiez si la création du fichier UDL est correcte. Ci-dessous une note d'application décrivant étape par étape cette procédure:
    * Creating a Microsoft Data Link file (.UDL) for Connecting to Microsoft Access in LabVIEW
    http://digital.ni.com/public.nsf/websearch/1D5EB4DCBD13106486256B9D005E11B0?OpenDocument
    Ensuite, testez l'exemple standard "Connection example.vi" fourni avec le toolkit Database Connectivity.
    Dans LabVIEW, allez dans le Menu Aide >> Recherche d'exemples ... puis sélectionnez Toolkits & Modules >> Connection aux bases de données >> Connection example.
    Si la connection échoue, l'exemple doit renvoyer une erreur avec un code et un descriptif. Ces informations sont indispensables pour débuter un débuggage (l
    es codes d'erreurs classiques sont référencés sur le web et des notes d'applications sont fournies pour les corriger).
    Cordialement.
    Matthieu Gourssies
    National Instruments France.

  • Memory leak when using database connectivity toolset and ODBC driver for MySQL

    The "DB Tools Close Connection VI" does not free all the memory used when "DB Tools Open Connection VI" connects to "MySQL ODBC Driver 3.51".
    I have made a small program that only opens and close the connection that I run continously and it's slowly eating all my memory. No error is given from any of the VI's. (I'm using the "Simple Error Handler VI" to check for errors.)
    I've also tried different options in the DSN configuration without any results.
    Attachments:
    TestProgram.vi ‏16 KB
    DSNconfig1.jpg ‏36 KB
    DSNconfig2.jpg ‏49 KB

    Also,
    I've duplicated the OPs example: a simple VI that opens and closes a connection. I can say this definately causes a memory leak.
    Watching the memory:
    10:17AM - 19308K
    10:19AM - 19432K
    10:22AM - 19764K
    10:58AM - 22124K
    Regards,
    Ken
    Attachments:
    OpenCloseConnection.vi ‏13 KB

  • Database connection not working across all Adobe programs

    I have a PDF form connected to an Access database via ODBC. On the form, I created a button that, when clicked, takes the data in the PDF and adds it to the database. The scripts for that action and the connection was established in LiveCycle Designer. I opened the PDF in Acrobat Pro and enabled Usage Rights for Reader (overwriting the file in the process). Here's what I find odd. The button works fine in Acrobat Pro, but when I open the PDF in Reader and try the button, it gives me an error saying that the accessor 'xfa.sourceSet.DataConnection.open();' is unknown. Why on earth would Adobe recognize the connection in Acrobat but not in Reader? That doesn't make sense to me, especially since I did enable the usage rights.

    I do not see where this permission is given in the enablement of Acrobat Professional Forms. What I see is the following:
    - Save form data
    - Commenting and drawing mark-up tools
    - Sign an existing signature field
    - Digitally sign the documen anywher on the page (only supported in Adobe Reader 8.0)
    I do not see connect to a database anywhere.
    Sabian

  • Multiple sessions in a single database connection.

    I have copied the following text from Forms Developer2000
    "At runtime, Form Builder automatically establishes and manages a single connection to ORACLE. By default, one user session is created for this connection. However, the multiple-sessioning feature of ORACLE allows a single client to establish multiple sessions within a single connection. ORACLE transaction-management and read-consistency features all are implemented at the session level, so creating multiple sessions allows a single user to have multiple, independent transactions."
    If ORACLE allows a single client to establish multiple sessions within a single connection, I want to leverage on this feature in my application which uses BC4J.
    Can anybody tell me if
    1. its possible achieve this in Java(BC4J).
    2. If Yes, How?
    regards,
    vikrant

    Thank you for your valuable suggestion.
    I believe createing multiple root Application
    Modules, will create as many number of connections to
    database, hence multiple transactions.
    But What I wanted was multiple sessions in a single
    connection, who's behavior will be similar to two
    different connections.Could you tell me the advantage you're looking for in multiple sessions in one connection vs. multiple connections (where connections may be pooled)?
    Thanks.
    Sung

Maybe you are looking for

  • Parameter Value passing issue to Web i report from Design Studio APP

    Hi all, I am trying to pass values to 2 parameters in a web I report called DIM1_REPORT and DIM2_REPORT. The values with space for example, Computer Sciences Corporation is getting passed as Computer\Sciences\Corporation Looks like the space is getti

  • Random SP2 error when starting oracle process through SHELL script

    Hi All, I am trying to process data in n-Number of tables through a package. The package is called through a shell script to create start data processing. All calls to the package are in a sql script which is basically exec calls- exec package.proces

  • ITunes says i need 64bit version to sync, I already have it

    iTunes gives me the following error when I plug in my iPhone: "This iPhone cannot be used because the required software is not installed. Run the iTunes installer to remove iTunes, then install the 64-bit version of iTunes." I'm running vista 64-bit

  • IMac as Secondary Thunderbolt Display

    Hi, I'm wondering if anyone knows how I might resolve these issues. I have a new 2013 27" iMac and have connected another new 27" iMac via Thunderbolt to use as a second display. I have two issues: 1. I have to press Command+F2 to use the iMac as a s

  • Object Buffer Function

    Hi, I need to automatically change the Confirmation Pricing Date to be the same as the 'Start Of Work' field (user entry) using a badi. I am planning on using the badi CRM_PRICING_BADI and a function module to read the Object Buffer for the current c