1 2 Previous Next 17 Replies Latest reply on Mar 9, 2011 9:28 PM by jschellSomeoneStoleMyAlias

    Using Java applet to connect to Oracle db

    J_Morgan
      Hi

      I'm a complete n00b when it comes to programming in Java.

      I want to create a webpage for the DBAs in my organisation. I'd like to have a drop down list of the TNS aliases listed in the local tnsnames.ora file. I'd then like username/schema and password entry boxes.

      On successful connection, I'd like to display a list of 'sections' and once a section has been highlighted, it shows a list of available sql scripts for that section. eg. ASM section, RMAN section, Diagnostics etc.

      Once a script has been selected, it goes off and runs against the database as that user and returns the output to the java applet.

      Is this possible and is it easily achievable? If so, where do I start?


      I've found this resource:

      http://download.oracle.com/javase/tutorial/uiswing/components/applet.html

      I was going to embed that in an HTML file and see how it works and go from there but there's no 'class' file so I can't get it running (I only have the JAR with embedded images).

      Are there any embedded java applet examples available for beginners which will help me to better understand what's going on behind the scenes?

      TIA
        • 1. Re: Using Java applet to connect to Oracle db
          Kayaman
          J_Morgan wrote:
          I'm a complete n00b when it comes to programming in Java.
          Then you'll want to save yourself a lot of time by not pursuing the goals you stated in your post.
          • 2. Re: Using Java applet to connect to Oracle db
            803795
            I agree with the previous post. its too advanced a topic for someone just starting out. I suggest you read my previous post about creating your first web based program (my first reponse in that article, not the two later ones). I also suggest you keep away from applets and learn JSP/Servlets well instead:

            Re: learning Java web applications
            • 3. Re: Using Java applet to connect to Oracle db
              J_Morgan
              Am I right in thinking that I'd need a tomcat installation to implement JSP / servlets? I was hoping I'd be able to just write a client side app and utilise the jdbc thin driver to connect to the databases.
              • 4. Re: Using Java applet to connect to Oracle db
                793415
                J_Morgan wrote:
                Am I right in thinking that I'd need a tomcat installation to implement JSP / servlets?..
                Tomcat or another servlet container, yes.
                ..I was hoping I'd be able to just write a client side app and utilise the jdbc thin driver to connect to the databases.
                How much do you value the DB and data? Applets are easily hackable, so if an applet can directly access the DB, so can a malicious hacker.
                • 5. Re: Using Java applet to connect to Oracle db
                  gimbal2
                  Andrew Thompson wrote:
                  How much do you value the DB and data? Applets are easily hackable, so if an applet can directly access the DB, so can a malicious hacker.
                  Exactly. Try this:

                  - compile your applet
                  - download a decompiler (like DJ java decompiler)
                  - use it to decompile your applet .class file
                  - be worried how easy that process was and how clean the output is
                  • 6. Re: Using Java applet to connect to Oracle db
                    jschellSomeoneStoleMyAlias
                    gimbal2 wrote:
                    Andrew Thompson wrote:
                    How much do you value the DB and data? Applets are easily hackable, so if an applet can directly access the DB, so can a malicious hacker.
                    Exactly. Try this:

                    - compile your applet
                    - download a decompiler (like DJ java decompiler)
                    - use it to decompile your applet .class file
                    - be worried how easy that process was and how clean the output is
                    Since the OP said....

                    +"I want to create a webpage for the DBAs in my organisation"+

                    That wouldn't seem to be a particular concern to me.

                    Although one might wonder what sort of DBAs would find this useful.
                    • 7. Re: Using Java applet to connect to Oracle db
                      jschellSomeoneStoleMyAlias
                      J_Morgan wrote:
                      Is this possible
                      Yes.
                      and is it easily achievable?
                      Not even close.
                      If so, where do I start?
                      1. Learn basic java
                      2. Learn about basic client-server architectures.
                      3. Learn about a J2EE server, say Tomcat
                      4. Learn the basics of database, including SQL
                      5. Learn advanced topics specific to your database to learn how to get 'section' data.
                      6. Learn about JDBC (do NOT use a J2EE server for this.)
                      7. Learn about applets.
                      8. Learn basics of security to insure that the design does not have security implications.
                      9. Learn about unit testing
                      10. Learn about error handling.
                      11. Put all of the above together to create a production ready server.

                      The above should do it.
                      • 8. Re: Using Java applet to connect to Oracle db
                        J_Morgan
                        jschell wrote:


                        Although one might wonder what sort of DBAs would find this useful.
                        If you're a DBA yourself, you can't tell me you've never written/used a shell script to help you run multiple sql scripts against db(s) to make your life easier? I have a complete shell script in place which does just this, connects to the database (currently over 250 here) using the tns alias provided, prompts for username/password, type of script etc. It then all gets dumped into an html file and apache makes it available to other users through a web-app I wrote in APEX a few years ago. Grid control has taken precedence over this way of doing things but I still use it occasionally if the agent is down (which happens more often than expected).

                        In this instance, I was simply trying to eradicate the extra step of puttying into a Linux box and running it all through a command prompt.

                        It also would have helped our developers who don't have direct access to the servers to diagnose their own problems rather than coming to the DBAs constantly.

                        I started writing a Windows batch script to replicate the shell script but came across a few hurdles (required knowledge of VBscript, ASP and ADO as well). I then thought 'why not have a go at Java'. I've not really had much exposure to Java development in any of my roles and though it would be a good excuse to try it out.

                        So, although you may not see the use, I would find it useful both as a handy way of getting info from the databases and as a basic intro into Java programming (depending on what's involved).

                        Edited by: J_Morgan on 09-Mar-2011 02:50

                        Edited by: J_Morgan on 09-Mar-2011 02:58
                        • 9. Re: Using Java applet to connect to Oracle db
                          YoungWinston
                          J_Morgan wrote:
                          So, although you may not see the use, I would find it useful both as a handy way of getting info from the databases and as a basic intro into Java programming (depending on what's involved).
                          As has already been suggested, this is far from basic. How long did it take before you could write the script you mentioned? Assume it will take longer in Java (and quite a bit longer before you're able to write a program that passes professional muster).

                          Winston
                          • 10. Re: Using Java applet to connect to Oracle db
                            J_Morgan
                            YoungWinston wrote:
                            As has already been suggested, this is far from basic. How long did it take before you could write the script you mentioned? Assume it will take longer in Java (and quite a bit longer before you're able to write a program that passes professional muster).

                            Winston
                            Ages! and to implement it into APEX even longer.

                            I'm not looking for a 5 minute solution - I wanted an excuse to write something in a language I'm not familiar with and Java seemed like a good choice.

                            I was looking really for advice on which direction/approach to use - after reading the posts here, it feels like I'm being talked out of it. It makes more sense for me working with a tangible example and seeing how the code underneath works rather than starting from scratch trying to read a 500 page Java for beginners book.
                            • 11. Re: Using Java applet to connect to Oracle db
                              Kayaman
                              J_Morgan wrote:
                              I was looking really for advice on which direction/approach to use - after reading the posts here, it feels like I'm being talked out of it.
                              When I talk people out of writing Java, it's because I want to save them some time (and also to make sure there are less competitors for my jobs...no wait...).
                              Especially in the "I don't have time/interest/skills to read a book, I want to write code!" cases. Nothing wrong with writing code, but it's more of the "Hello, world!" type and other boring things that you'll need to go through.
                              It makes more sense for me working with a tangible example and seeing how the code underneath works
                              I've heard that a lot, but I've yet to meet anyone who actually learned Java by programming things that are completely beyond his skills.
                              rather than starting from scratch trying to read a 500 page Java for beginners book.
                              You don't want to start from scratch then, okay. What kind of programming skills do you have?
                              • 12. Re: Using Java applet to connect to Oracle db
                                J_Morgan
                                Kayaman wrote:
                                When I talk people out of writing Java, it's because I want to save them some time (and also to make sure there are less competitors for my jobs...no wait...).
                                Trust me, there's no risk of me being a Java competitor! I'm quite happy being a DBA :)
                                You don't want to start from scratch then, okay. What kind of programming skills do you have?
                                I agree with you that you need a good grounding in programming in order to code - you need to understand the basics before moving onto more involved projects. I've 'dabbled' with numerous different languages but never really settled on one specific one - basically a jack of all trades, master of none (I spent a few years in C++ but never developed anything substantial as there was never any requirement for it in my job). However, as Java (cough Oracle couch) seems to be taking over the world, I'd like to get into it and make the effort to understand it. I guess the book reading stage wouldn't be a bad idea - I'm just a bit impatient!
                                • 13. Re: Using Java applet to connect to Oracle db
                                  gimbal2
                                  J_Morgan wrote:
                                  I guess the book reading stage wouldn't be a bad idea - I'm just a bit impatient!
                                  Fix that problem ASAP. You cannot be impatient as a developer, because then you'll be back here for every little problem you will encounter.

                                  - research takes time, but it is an important part of the job
                                  - debugging takes time, but it is an important part of the job
                                  - creating a proper application design takes time
                                  - writing proper unit tests can take lots of time (my experience: writing unit tests that actually hold any water can double development time)
                                  - testing takes time
                                  - documentating takes time

                                  Of the entire development process, you'll only be spending a small part of it actually writing code. So please, learn to be more patient. Start now: actually do take the time to read a book. Or at least work through Oracle's Java tutorial.
                                  • 14. Re: Using Java applet to connect to Oracle db
                                    abillconsl
                                    J_Morgan wrote:
                                    Kayaman wrote:
                                    When I talk people out of writing Java, it's because I want to save them some time (and also to make sure there are less competitors for my jobs...no wait...).
                                    Trust me, there's no risk of me being a Java competitor! I'm quite happy being a DBA :)
                                    So from this and your other posts here, it sounds like you're experienced programmer, even though not with Java. It sounds like you have a fundamental understanding of OO concepts too, and since you know some C++, you evidently know a bit about GUI development. As a DBA you know a lot about databases, and I would presume a lot about security.

                                    So if that is so, maybe you should give it a try. Only thing is, I'd suggest NOT doing an Applet for this. Servlet/JSP/Tomcat is a great approach. But you could also do this as a desktop application and distribute it via Java Web Start.
                                    You don't want to start from scratch then, okay. What kind of programming skills do you have?
                                    I agree with you that you need a good grounding in programming in order to code - you need to understand the basics before moving onto more involved projects. I've 'dabbled' with numerous different languages but never really settled on one specific one - basically a jack of all trades, master of none (I spent a few years in C++ but never developed anything substantial as there was never any requirement for it in my job). However, as Java (cough Oracle couch) seems to be taking over the world, I'd like to get into it and make the effort to understand it. I guess the book reading stage wouldn't be a bad idea - I'm just a bit impatient!
                                    I certainly understand the impatient part. Impatience certainly is difficult to overcome. But if you feel you are up to the challenge, go for it. Just play it safe and one step at a time. I imagine the JDBC part should come pretty naturally to a DBA.

                                    If you do go the Servlet/JSP/Tomcat route, you will need to learn J2EE and it will take longer. Regards,

                                    ~Bill

                                    PS: If you decide to not do this, you are aware of Toad? A good, if a bit overwhelming tool, but very nice for a DBA I should think.

                                    Edited by: abillconsl on Mar 9, 2011 10:32 AM
                                    1 person found this helpful
                                    1 2 Previous Next