Menu

db connection

Help
MisterT
2005-03-27
2013-06-03
  • MisterT

    MisterT - 2005-03-27

    Hi,
    is it possible to retrieve the dbforms database connection con on the JSP scripting level?

    Thanks + regards T.

     
    • Henner Kollmann

      Henner Kollmann - 2005-03-27

      Yes you can. Use <getConnection> tag!

      Henner

       
      • Ivan Codarin

        Ivan Codarin - 2005-03-28

        Another way is to implement in a class/bean (also a static class if you need it) a method like this:

        public static Connection getDbformsConnection() {
                Connection conDbforms;
                conDbforms=null;
                try {
                   
                    conDbforms = DbFormsConfigRegistry.instance().lookup().getConnection();
                } catch (Exception e) {
                    System.out.println("Error getting dbforms connection:"
                            + e.getMessage());
                }

        Cheers

         
        • Henner Kollmann

          Henner Kollmann - 2005-03-28

          That's the way the getConnection tag works!

          Cheers
          Henner

           
          • Ivan Codarin

            Ivan Codarin - 2005-03-29

            Yes,
            I use the method

            "public static Connection getDbformsConnection() "

            of my previous post to in my beans or external POJOs to share the same dbform-connection without creating new ones... (in this way I should use also the pool-connector).

            Cheers

             
        • MisterT

          MisterT - 2005-03-29

          Thanks for your class/bean snippet above. Now I could use a connection from the dbforms framework in my bean.

          regards T.

           
      • MisterT

        MisterT - 2005-03-28

        Hi,
        this is what I've tried:

        <db:getConnection id="testCon">
        <%
            int Row = 0;
            String lockUserQuery = "foo";
            try
            {
                Statement stmt = testCon.createStatement();
                Row = stmt.executeUpdate(lockUserQuery);
                stmt.close();
            }
            catch (SQLException e)
            {
                e.printStackTrace();
            }

        %>
        </db:getConnection>

        Unfortunately there's a compiler failure: cannot resolve symbol
        symbol  : variable testCon

        What's wrong with my code? How do I pass the connection to the script?

        Thanks in advance T.

         
        • Henner Kollmann

          Henner Kollmann - 2005-03-28

          Because that's not the way to use tags. If you reaally want to write java code into your jsp the example Ivan wrote was much simplier to use.
          The getConnection tag is usefull if you want to use the sql jsp standard tag library.

          Henner

           
          • MisterT

            MisterT - 2005-03-28

            OK, seems that I'm not really deep into the JSP issue...  ;-)
            The backround is, to set a lock flag in a record, during a user calls the JSP view of a record. This will help to prevent for double using a record.

            Maybe it's a good task to put it in a bean.

            Thanks for your hints + regards T.

             
            • Henner Kollmann

              Henner Kollmann - 2005-03-28

              Hmm - and how will you unlock the record? Think about your user - he will stay on the record he just visited for the rest of his life (Or up to the end of the session, session timeout). How will you do the unlock in this case?

              Henner

               
              • MisterT

                MisterT - 2005-03-28

                Good question, we had discussed a lot about it.

                There's an applet for editing server side documents running in our web application. This applet has a communication with our server and while the user press "save and exit" inside the applet, we will check back the document and unlock the record in our db.

                regards T.

                 

Log in to post a comment.

MongoDB Logo MongoDB