JDBC implementation in an application ... newbie question

Hi all ...
My first post here. Hope Im at the right place.
I've just started out with java, had gotten the basics and started to develop a little. Now, I would like to involve a MySQL database. I have made a few small connection tests and selections/insertions and all works fine.
Now, I have been googleing the net a few times but I cant seem to find any good source of information on how you implement the DB layer in an application. How is it usually done?
I got a few classes that need got get info from MySQL to fill a ArrayList for example. I need authentication agains the MySQL database for users. Regular things. I understand how this should be done but not how to go about implementing it. Where should the DB connection be done so I dont have to make a connect in every method I want DB access in. Please, anything would be helpful.
Thanx in advance ...
/Roger

Hi all ...
My first post here. Hope Im at the right place. Welcome. You've come to the right spot.
>
I've just started out with java, had gotten the
basics and started to develop a little. Now, I would
like to involve a MySQL database. I have made a few
small connection tests and selections/insertions and
all works fine. Excellent.
Now, I have been googleing the net a few times but I
cant seem to find any good source of information on
how you implement the DB layer in an application. How
is it usually done? I don't think there's one way that everyone would agree on. I'm sure your Google search has turned up a lot of stuff: object-relational mapping, JDO, entity EJBs, the new Java Persistence API, straight JDBC.
One pattern that's popular these days is the Data Access Object, or DAO. Google for that and see what you think.
The idea is to isolate the SQL stuff into a single package of classes.
I got a few classes that need got get info from MySQL
to fill a ArrayList for example. I need
authentication agains the MySQL database for users.
Regular things. I understand how this should be done
but not how to go about implementing it.
Where should
the DB connection be done so I dont have to make a
connect in every method I want DB access in. I'm not sure what you mean by this, but I would say that a fresh connection for each database unit of work is a good idea. The idea is to get a connection when you need it, use it, and close it so somebody else can use it. It scales better that way.
You'll want to read about connection pooling, too.
%

Similar Messages

  • FOD application - newbie question

    Hi,
    I'm a newbie to Jdeveloper/ADF. I have downloaded FOD demo application from OTN site and I installed the schema and could build the task flow and screens as described in the demo. Currently, I'm running into problems like order id displaying a negative number, buttons not working etc.,. I'm finding it hard to debug as I'm using it very first time. It will really helpful to download a solutions for the FOD demo app and learn by example from there. is it possible to download a FOD demo app with solutions?. any ideas/pointers are really appreciated.
    Thanks,
    Surya

    The FOD demo is a fully functional application that works - if you see something specific that you think is broken there, please let us know which specific screen you are seeing problems with and what the problems are.
    If you want a tutorial that will guide you through building an application start here:
    http://www.oracle.com/technetwork/developer-tools/jdev/overview/jdeveloper-reviewrguide-086026.html
    and
    http://www.oracle.com/technetwork/developer-tools/jdev/overview/index-100269.html

  • Total Newbie Question ... Sorry :-(

    I know it's a windows thing, and I am now converted to Mac but I gotta know this because it's doing my head in. It's a complete stupid green gilled newbie question.
    When installing new programs on a Mac can you create shortcuts to the programs on the Dock? I did what I THOUGHT it would be, i.e I made an Alias and stuck it in the dock, but on rebooting my Mac later on, in place of the shortcuts where 3 question marks which when clicked on did absolutely nothing???
    Help?
    A.L.I
    Windows XP Pro Desktop, Macbook Pro, 60GB iPod Video   Mac OS X (10.4.5)   OS X

    You aren't installing something from a dmg file are you? The dmg is a disk image – kind of a virtual CD. So when you double click the dmg and then get the little disk/hardrive/custom icon on your desktop that is the same as if you had mounted a CD. You then need to drag the application off of that "CD" into your application folder. Then it is truly installed.
    You can then "eject" the icon your your desktop. This is what happens when you shutdown and without remounting the image your dock shortcut can't find the original.
    Just a thought.

  • Domain name settings - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name? Any option?

    Setting up a mailserver and making sure it doesn't suddenly turn into a spambox is not something you do with the use of a few commands. I suggest to dive into the Solaris admin guide on docs.sun.com and read up on e-mail and network services.
    If that is asking too much of your time you'll be better off getting your ISP to handle all this for you.

  • Domain Name settings in Solaris - Newbie question

    Sorry for a newbie question!
    I am already pointing a domain name to web hosting for email account. Now, I need an application server to run ERP software and Oracle, and installing Solaris and Oracle need a domain name.
    If I point my domain name to the server, how do I receive emails from web hosting???
    Install an email server to the application server instead? What can I do if I want the same domain name?

    Your questions are completely off-topic for the forum.
    These SunOS forums are for questions on <i>"how do I install my OS"</i>
    You particular question is in the <i>"how can I install Solaris while using the CD drive"</i> forum.
    So, if you had a question on how to edit the /etc/inet/hosts file to establish a FQDN on the computer, then it might be appropriate for the forum.
    Unfortunately, I don't have a clue on where to redirect you, except perhaps to the Sun Java Enterprise System suite of applications?

  • Multiple version of JRE in company..How to manage? (newbie question)

    Greetings..this is a newbie question
    We have 48 versions of JRE running in on XP IE6 in our company.
    Some version beat up other JAVA applications.
    It's a mess.
    How can anyone manage this many versions?
    Can we consolidate down to a few versions?
    I saw some posts on changing the JRE dynamically or perhaps using a wrapper with a product from "sourceforge".
    Are these viable?
    Thanks in advance

    We have 48 versions of JRE running in on XP IE6 in
    our company.
    Some version beat up other JAVA applications.
    It's a mess.can you elaborate on how some versions "beat up" other apps?
    How can anyone manage this many versions?you don't, each computer should periodically upgrade (IMO) but you shouldn't care. if you do, tell your users to load the latest version
    Can we consolidate down to a few versions?sure
    I saw some posts on changing the JRE dynamically or
    perhaps using a wrapper with a product from
    "sourceforge".
    Are these viable?i have no idea what this is, but I have doubts about your problem, if it exists at all

  • Newbie question: ""dynamic"" casting

    Hello all,
    <br>
    I have a quite newbie question. I have this class hierarcy:
    <br>
    A
    |_A1
    |_A2
    |_A3
    |_A4
    |_A5
    |_.....
    <br>
    in some part of my code I have this:
    <br><br>
    if (object1 instanceof A){
    if (object1 instanceof A1)      {A1   object2 = (A1) e;}
              if (object1 instanceof A2)      {A2   object2 = (A2) e;}
              if (object1 instanceof A3)      {A3   object2 = (A3) e;}
              if (object1 instanceof A4)      {A4   object2 = (A4) e;}
              if (object1 instanceof A5)      {A5   object2 = (A5) e;}
    object2.callMethod();
    <br><br>
    Is there any way to do this type of casting just in one line? I mean, I just want to cast object1 to the class it is instanceof. If it is instance of A1, I want to be casted to A1, if it is A2 to A2, etc...
    <br><br>
    Thanks you in advance.

    kamikaze04 wrote:
    In fact I know what object1 is on execution time,Which doesn't help your compiler at all, when it's task to link and verify method calls.
    because the code posted at the top is working well, i just want to avoid repeating that if's for all the new classes Ax I will create. Big "code smell" here.
    In other words if i had from A1 to A200 i dont want to have 200 if's to cast it to the class it is and then execute it's method.You could call the method "doMagic()" and make it abstract in A. Then you can implement it in all Ax classes and would never have to worry about casting in the first place, because A.doMagic() would automagically do the right thing. Polymorphism.

  • SG200-08 Newbie Questions

    I have recently purchased the SG200-08 Smart Switch, but I have a few "newbie questions" about it as I get started using it.
    The on board firmware shows 1.0.1.0. Is that the latest firmware to the switch?
    Do I need to enable IPv6 Auto Configuration and DCHPv6 in my switch settings to be ready for IPv6 as my ISP rolls it out down the road?
    How do I go about changing the switch's username? I was able to easily change the password, but having issues getting the username to change.
    Do I need to do anything about the LLDP-MED settings? What exactly is that?
    How do I confugure the System Time Settings so the switch functions in my time zone (USA Central Time)?
    Thanks a bunch for any assistance!

    Hi Nathan,
    My guess is that NAT is already on - you have one public IP address from your ISP. Your router will use NAT (network address translation) to allow multiple clients (and either dynamically assign them private IPs via dhcp or you set them statically) to connect to the internet using the one public IP. It also sounds like your RV042G is assigning both ipv6 and ipv4 addresses, and theres nothing wrong with that. Unless you have specific information re: ipv6 from your isp, however, I would suggest not worrying about it until you hear from them. Are your macs connected to the router via the SG200 switch? If so, it looks like its passing ipv6 just fine.  UPnP is something completely different - thats with opening ports like you mentioned - its a way that your devices can communicate with the router to automatically enable the proper port forwarding for the device/application.
    Regarding the username, create a new user account. I don't think you can edit the cisco user, but try deleting it after creating and testing a new user account..
    I'm not familiar with the Polycom system, but I would leave the settings as default unless you are using true IP phones (rather than an ATA adapter). From a quick google of the polycom device, I don't think you will gain anything from LLDP/CDP as the handsets use regular cordless phone freqs. With my setup, we use cisco IP desk phones and cordless wifi phones, CDP makes life easy as the cisco access point, wifi phones, cisco switch, and cisco desk phones (connected via ethernet) see each other and know what they're dealing with automatically.
    I don't see the SNTP setting for unicast / broadcast that you're looking at. For the switch to get the time from a sntp server, under administration -> time -> sntp settings, add a server, and then back on time-> system time, enable sntp server as the main clock source. What are you using as your sntp source? Do you have an internal sntp server? You don't need to enable dhcp on the sntp server.
    May I also point you to the two manuals, I think they may be helpful:  RV042G  & SG200
    Hope thats helpful.
    Best,
    David
    Please rate any helpful posts.

  • Newbie question. coldFusion w/ Flex 2 tutorial

    Hello.
    I am very new to F2 and CF. Fairly proficient at Flash, DW,
    css, html, etc. I have purchased and worked through a couple really
    great F2 and CF books. I am able to construct some good basic stuff
    with either. But am not really finding a tutorial or book that is
    exclusively committed just to the subject of to using CF with Flex
    2. There always seems to be a just a cursory mention, or a
    brush-by, but not much more than that. I get it: if you got this
    far, you probably arlready know everything about the two and
    shouldn't need such.
    If you could point me to a couple good references, I'd be
    very appreciative. I'm looking for a good step-by-step, just on
    this subject.

    Thank you. You are right on with the direction of your
    answer.
    Immediately, I am just trying to create a simple method of
    add/edit/delete records to tables from forms that I could access
    remotely with Flex 2. I just assumed that CF would be the best
    method, both being Macradobe products. If I am wrong about that, so
    be it. Utlimately, I would like to print specific "quotes" relative
    to specific customers and products to .pdf. This is for my own
    personal use (as an insurance broker). Not commercial. Nor is
    anyone paying me to develop this.
    Maybe a better newbie question would be: what would be the
    preferred method to add/edit/delete records, remotely, from a Flex
    2 application for later printing to .pdf based on various selection
    criteria? I have figured out how to do this on my own stand-alone
    machine. Now I want to be able to do it remotely from anywhere.
    I'm
    not looking for instruction from anyone here, just direction
    to your favorite learning tools so that I can dig in and learn.
    I bought the books you recommended (adding to my own Library
    of Congress).
    Thanks again!

  • Distribute JDBC driver with our application

    we are not an oracle customer, but we develop an application that has a component that leverages the JDBC driver to connect to the Oracle database. is it ok to distribute the JDBC driver with this application component? i don't see anything in the licensing policy that prevents us from doing so. do we need to be a member of the oracle partner network at a certain level?
    thx.

    we are not an oracle customer, but we develop an application that has a component that leverages the JDBC driver to connect to the Oracle database. is it ok to distribute the JDBC driver with this application component? i don't see anything in the licensing policy that prevents us from doing so. do we need to be a member of the oracle partner network at a certain level?
    You were REQUIRED to accept the license agreement prior to downloading the JDBC driver software. It is expected that you will actually READ the license agreement prior to accepting it.
    Oracle Database 12c Release 1 JDBC Driver Downloads
    You must accept the OTN License Agreement to download this software.
    That license agreement CLEARLY answers your question so you should re-read it. You are bound by ALL of the terms but this is copied directly from that link:
    License Rights
    We grant you a nonexclusive, nontransferable limited license to use the programs: (a) for purposes of developing, testing, prototyping and running applications you have developed for your own internal data processing operations; (b) to distribute the programs with applications you have developed to your customers provided that each such licensee agrees to license terms consistent with the terms of this Agreement, you do not charge your end users any additional fees for the use of the programs, and your end users may only use the programs to run your applications for their own business operations; and (c) to use the programs to provide third party demonstrations and training. You are not permitted to use the programs for any purpose other than as permitted under this Agreement. If you want to use the programs for any purpose other than as expressly permitted under this agreement you must contact us, or an Oracle reseller, to obtain the appropriate license. We may audit your use and distribution of the programs. Program documentation is either shipped with the programs, or documentation may accessed online at http://www.oracle.com/technetwork/indexes/documentation/index.html.
    Item (b) above begins with 'to distribute the programs . . .'
    Yes - you can distribute the JDBC driver as long as you abide by that license agreement in its entirety (not just the quote I provided).
    Any and all questions need to be directed to Oracle as noted in the License Agreement. No one on the forums can speak for Oracle.

  • Newbie Question. just installed IE7.. how do I set up a local host to preview sites?

    Sorry for the newbie question... but it's been a long time since I have done this
    Thanks!

    Just define your site in DW as always.  For a static site, that's all you need to do.

  • Newbie Question about FM 8 and Acrobat Pro 9

    Hello:
    I have some dcouments that I've written in FM v8.0p277. I print them to PDF so that I can have a copy to include on a CD and I also print some hard copies.
    My newbie question is whether there is a way to create a  PDF for hard copy where I mainitain the colors in photos and figures but that the text that is hyperlinked doesn't appear as blue. I want to keep the links live within the soft copy. Is there something I can change within Frame or with Acrobat?
    TIA,
    Kimberly

    Kimberly,
    How comes the text is blue in the first place? I guess the cross-reference formats use some character format which makes them blue? There are many options:
    Temporarily change the color definition for the color used in the cross-reference format to black.
    Temporarily change the character format to not use that color.
    Temporarily change the cross-reference definition to not used that character format.
    Whichever method you choose, I would create a separate document with the changed format setting and import those format into your book, create the PDF and then import the same format from the official template.
    - Michael

  • Using 10.2.0.1.0 JDBC drivers on an application deployed to OraclAS10g R2

    Hi!
    How can I use the latest 10.2.0.1.0 JDBC driver in java-application deployed to OraclAS10g R2?
    My config:
    MS Windows 2003 EE, P4 1.5 GHz, 512 Mb RAM.
    I tried to use multi home installation:
    1) OAS10gR2 - KEY_OAS10;
    Home: KEY_OAS10
    Path: D:\Oracle\OAS10
    2) Oracle10g R2 Client
    Home: KEY_ORA10C
    Path: D:\Oracle\ORA10C
    I added environment variable in opmn.xml like this:
    <ias-component id="OC4J">
    <environment>
    <variable id="ORACLE_HOME" value="d:/Oracle/ORA10C"/>
    <variable id="PATH" value="d:/oracle/ORA10C/LIB;d:/oracle/ORA10C/bin" append="true"/>
    <variable id="NLS_LANG" value="RUSSIAN_CIS.CL8MSWIN1251"/>
    </environment>
    and I added java parameter:
    -Djava.library.path=d:\oracle\ORA10C\bin
    and I added: HKLM\SOFTWARE\ORACLE\ORACLE_HOME=D:\Oracle\ORA10C
    My path: D:\Oracle\ORA10C\bin;D:\Oracle\OAS10\bin;D:\Oracle\OAS10\jlib;D:\WINDOWS;D:\WINDOWS\System32;D:\WINDOWS\System32\Wbem
    Summary, I have got this error :
    java.lang.UnsatisfiedLinkError: D:\oracle\ORA10C\BIN\ocijdbc10.dll: The specified procedure could not be found at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    How properly swap JDBC OCI driver ?

    sisaev,
    Have you seen this Web page:
    http://www.oracle.com/technology/tech/java/oc4j/1013/howtos/how-to-swapjdbclib/doc/readme.html
    Good Luck,
    Avi.

  • Newbie Question:  How much computer do I need?

    Newbie Question:
    I would like to use MainStage 3 in a live performance environment to play bars, parties, etc.  I'm not looping, using it to playback recordings, processing outboard equipment or vocal processing.  I want to stop carrying Rolands, Nords, Korgs, etc and get to a controller and a rack with a Mac Mini in it.
    I tested a download of Mainstage 3 on my home Mac Mini (late 2012, 3.5 Ghz i5, 4GB RAM, 500GB drive) and it seemed to run fairly well.  $30 well invested so I trekked forward... I purchased a Mac Mini (late 2009,  2.52GHz Core 2 Duo, 6GB RAM, 128GB SSD) for $200.  I started to do more elaborate keyboard setups to see how the CPU would hold up.  It typically runs from 30% to 50% of capacity (CPU and Memory)  It actually boots and runs better than the i5.  I hear the occasion gitch, but it actually seems to be getting better in time (or I'm rock and roll deaf.
    I got a rack, an Airport Express, a Radial USB interface and a Nektar Panorama P6.  It's starting to get expensive, but I'm emboldened by the actual quality for the sound and the flexibility of arranging for live performance.  What used to take me two and three keyboards to play, I can now fit on one performance patch.
    OK, now the question... am I at the limits of this little Core 2 Duo?  Should I upgrade the i5 with more RAM and a bigger SSD and use that?  Should I get a new(er) i7 and bite the $1,500 bullet for the additional RAM and SSD?
    I see that most of you are running pretty nice Macbook Pros with i7 and lots of everything.  My needs are modest; am I OK? 
    BTW, I want to run a Mac Mini in a box because I don't want to carry a laptop out in the open.  If I was doing bigger shows I wouldn't care but I play some rowdy bars and constantly have folks hanging off me while I'm playing.  It's fun, but hard on gear.  If you can't drop it or dip it in beer, it won't last long where I work.
    Matt Donnelly

    Rule of thumb: newer and faster is better. But, depending the complexity of your needs you may be OK with an older Mac. Some glitches that happen in a live performance are due to loss of communication with USB or Firewire inputs, so make sure they're secure. I recently upgraded from a 2010 Mac Mini 2.6 dual core with 16 GB RAM, which was used live for nearly four years, to the latest Mac Mini 3.0 i7 with 16 GB RAM and a 500 GB SSD. I was getting an occasional stuck note with the older one. The new one is rock solid. Some of my patches may have up to a dozen channel strips mapped to three keyboards. The Mini is mounted in a rack next to a MOTU Ultralite Hybrid. It is a good idea to map a panic button on your keyboard to controller # 123(all notes off). Also, you might want to invest in a battery backup power supply(APC, Cyberpower, etc.-$40-$60) to protect your Mac against power loss, which can damage you hard drive.

  • How to implement a forms application with an application server

    Hi,
    I want to implement a forms application with OAS version 10.1.0.
    How to configure? Where can I find some documents?
    Max

    See
    http://www.oracle.com/technology/documentation/appserver.html
    and
    http://www.oracle.com/technology/products/forms/index.html

Maybe you are looking for

  • How do I move photoshop to new mac and keep my downloaded fonts?

    Hi there. I am planning to buy a new MacBook very soon and am beginning to sort out all my files in preparation. I currently have Adobe Photoshop CS and have quite a few fonts on there that I have downloaded and would like to transfer everything to m

  • External HD doesn't work.

    My Mac Mini does not see my Hitachi XL1000 external hard drive.   The drive does not appear in the Time Machine preferences, and even more ominously it does not appear in the list of drives in Disk Utility. I have been using it to back up two differe

  • After Effects CC 2014,0 H264 Media export

    Windows 8.1 (absolutely nothing to do with the problem) Quicktime version 7,7,5 (absolutely nothing to do with the problem) After Effects CC 2014.0 Unable to export media with h264 codec of the same quality as in After Effects CS6, Media Encoder CC 2

  • Acrobat 3D Toolkit - texture & color issue - just light gray color

    hi there, when I open a 3D model in acrobat 3D toolkit, the different textures have all the same color R:192 G:192 B:192. Sort of light gray within the whole model ... If I open an other model and drag it into the one already opened, then the texture

  • SAP HR Development

    I need to code in ABAP, a determination of possible Workflow receivers  base on an authorisation amount stored in HR. i.e i need to extract from HR whether a user has the correct authorisation to approve a workflow based on the users amount e.g if i