Connecting to database -- New Bie Pl help

Hi all,
I have posted this question y'day & somebody asked me to post in this forum. So I thought I would. My question is :
How to I connect to database. I know some thing to get connected to database. If I am not wrong,
I will be needing a driver, datasource. If i am missing anything then please let me now.
I will be using jdbcodbc bridge driver which we get by default when we download jdk. But how do i create datasource. I want to use Tomcat as my server.
Please help me in this regard. I have heard of mySQL as free database. Is it true & how do I use it.

Here's more help:
http://developer.java.sun.com/developer/Books/javaprogramming/begjava2/ch19.pdf
What does Tomcat have to do with this? Is this for a J2EE app? If you're just using straight Java (no J2EE, JSP, etc), then you don't need Tomcat.
jdbcodbc is for talking to Microsoft Access databases from Java - if you are using MySQL, Oracle, Sybase, or most of the others, you will need a database specific driver module.

Similar Messages

  • New bie needs help on how to start...

    Hi there java gurus,
    I am very new to java & I have a little knowledge on the java architechture. I have some experience in web scripting languages like PHP, ASP & javascript/vbscripts etc.
    I want to master java. I want to be able to create java GUI applications that connects to database and do the required stuffs. I have little experience on creating java applets.
    But now I want to start with creating a GUI application to store my personal accounts. Later I want to convert that into a commercial one.
    My questions are:
    What free database I can use for my application?
    Developing GUI application in java is advisable? ie is java GUI faster to develop than developing in MS VB & VB.net?
    Can java code be protected? or it is easy to decompile? A friend of mine told something about decompiling jars.
    I understand that the nice thing about java is, it is multi platform & a well organised programming language.
    Please give me whatever advise is necessary for this new-bie to get going quickly.
    Note: I have just installed netbeans as java development IDE which comes with the latest java. Is this a good choice or there are any other choices?
    Thanks
    Hameed

    What free database I can use for my application?You can use any database which support JDBC. I know Mysql and Postgresql supports it.
    Developing GUI application in java is advisable? ie
    is java GUI faster to develop than developing in MS
    VB & VB.net?I dont think GUI programming is easier than VB in Java although i want to. There are some layouts (gridbaglayout) to specify the positions of your components in a platform independent way but they are not much easy.
    You have two choice (i think) if you dont want to work with those managers:
    1. You can set your layout to null and use absolute positions of the components to layout as in VB. There are some specific layouts in some IDEs to do this too. (AbsoluteLayout in Netbeans)
    2. You can wait for the new layout manager which is very powerfull for designing form like GUIs as far as i see. There is a java.net project for it. Unfortunately i dont remeber its name.
    In fact i am using Matisse(http://www.netbeans.org/kb/articles/matisse.html) in development builds of Netbeans. I reccomend you to use it for just practicing since you will not be able to open the forms designed with experimental Matisse in the stable release!
    >
    Can java code be protected? or it is easy to
    decompile? A friend of mine told something about
    decompiling jars.Yes the pure java classes can be decompiled perfectly. You need to use an obfuscator if you want to protect your code.
    Here is an example: http://www.retrologic.com/
    Note: I have just installed netbeans as java
    development IDE which comes with the latest java. Is
    this a good choice or there are any other choices?I think it is the best choice. But Eclipse and IntelliJ IDEA are also widely used.
    Thanks
    HameedGood luck.

  • How to connect the database?

    I'm new for oracle developer/2000.
    I installed oracle database 8i in windows 2000 server side, installed developer 6i forms builder in windows(NT) 2000 professional client side. That is all I was done.
    I start forms builder, but I can not connect the database from forms builder.(I configured NET8,and i can connect the database using NET8)
    Please help me.What should I do next? installing more software? installing server side or client side? more configuring? what else?
    Thank you in advance.

    Hi,
    This is not a question particular to portal applications. It should be posted on the general forum. Anyway, please check
    if you have configured the tnsnames.ora on your client machine. You should have an entry for the db connection there.
    Thanks,
    Sharmila

  • Help: FORMS SERVER cannot connect to database (forms patch9)

    Hi:
    I've installed oracle 9i database and oracle 9ias 1.0.2.2.2a.
    I configured FormsServlet and it's working very well as i suceed my test in http://machina.domain/servlet/oracle.forms.servlet.ListenerServlet!
    The problem is that i cannot connect to the database and i got the error ORA-12203 TNS: Unable to connect to destination!
    I've changed jserv.properties as recommended in 9ias 10222 release notes by commenting the wrapper.env=ORACLE_HOME in OJSP because it conflicts with forms server home.
    I've read all about this, and i still cannot connect to the database.
    I'm using a forms servlet configuration with IE JVM.
    If anyone can help me... i apreciate it!
    By the way in my jserv.properties forms server config i have:
    # Oracle Forms and Reports Servers
    wrapper.classpath=C:\ORACLE\806\forms60\java\f60srv.jar
    wrapper.classpath=C:\ORACLE\806\forms60\java
    If i have this the Test native method call (JNI) fails, but forms server keeps running. The error is:
    Calling RunformProcess.nInitLib()...
    RunformProcess.nInitLib() failed:
    java.lang.NoClassDefFoundError: oracle/forms/servlet/RunformProcess
    Your server configuration needs correcting. Please refer to the Forms documentation for details
    If i comment the f60srv.jar as showed here i suceed the test
    # Oracle Forms and Reports Servers
    # wrapper.classpath=C:\ORACLE\806\forms60\java\f60srv.jar
    wrapper.classpath=C:\ORACLE\806\forms60\java
    So... anyone help ?
    Ricardo
    PS: I can't understand why oracle keep sending huge amounts of releases of products and everytime they send a new release, that new release keeps coming with new bugs.

    Hi:
    This just connection problem just happen if i use formsservlet http connect mode. if i use normal HTTP (without servlet)connect mode with Jinitiator (1.1.8.16) i successfully connect to database (oracle 9i).
    Anyone there using 9ias 1.0.2.2.2a with forms server servlet and oracle database 9i ?
    thankx

  • Connecting to database help

    First let me say sorry as i have already started this post in another thread, but know one seems to be replying to it any more. the other thread can be found out: http://forum.java.sun.com/thread.jspa?messageID=9413573
    package coreservlets;
    public class Catalog {
    private static CatalogItem[] items =
        {new CatalogItem
            ("hall002",
             "<I>Core Web Programming, 2nd Edition</I> " +
               "by Marty Hall and Larry Brown",
             "One stop shopping for the Web programmer. " +
               "Topics include \n" +
               "<UL><LI>Thorough coverage of Java 2; " +
               "including Threads, Networking, Swing, \n" +
               "Java 2D, RMI, JDBC, and Collections\n" +
               "<LI>A fast introduction to HTML 4.01, " +
               "including frames, style sheets, and layers.\n" +
               "<LI>A fast introduction to HTTP 1.1, " +
               "servlets, and JavaServer Pages.\n" +
               "<LI>A quick overview of JavaScript 1.2\n" +
               "</UL>",
             49.99),
          new CatalogItem
            ("lewis001",
             "<I>The Chronicles of Narnia</I> by C.S. Lewis",
               "The classic children's adventure pitting " +
               "Aslan the Great Lion and his followers\n" +
               "against the White Witch and the forces " +
               "of evil. Dragons, magicians, quests, \n" +
               "and talking animals wound around a deep " +
               "spiritual allegory. Series includes\n" +
               "<I>The Magician's Nephew</I>,\n" +
               "<I>The Lion, the Witch and the Wardrobe</I>,\n" +
               "<I>The Horse and His Boy</I>,\n" +
               "<I>Prince Caspian</I>,\n" +
               "<I>The Voyage of the Dawn Treader</I>,\n" +
               "<I>The Silver Chair</I>, and \n" +
               "<I>The Last Battle</I>.",
             19.95),
          new CatalogItem
            ("alexander001",
             "<I>The Prydain Series</I> by Lloyd Alexander",
               "Humble pig-keeper Taran joins mighty " +
               "Lord Gwydion in his battle against\n" +
               "Arawn the Lord of Annuvin. Joined by " +
               "his loyal friends the beautiful princess\n" +
               "Eilonwy, wannabe bard Fflewddur Fflam," +
               "and furry half-man Gurgi, Taran discovers " +
               "courage, nobility, and other values along\n" +
               "the way. Series includes\n" +
               "<I>The Book of Three</I>,\n" +
               "<I>The Black Cauldron</I>,\n" +
               "<I>The Castle of Llyr</I>,\n" +
               "<I>Taran Wanderer</I>, and\n" +
               "<I>The High King</I>.",
             19.95),
          new CatalogItem
            ("rowling001",
             "<I>The Harry Potter Series</I> by J.K. Rowling",
             "The first five of the popular stories " +
               "about wizard-in-training Harry Potter\n" +
               "topped both the adult and children's " +
               "best-seller lists. Series includes\n" +
               "<I>Harry Potter and the Sorcerer's Stone</I>,\n" +
               "<I>Harry Potter and the Chamber of Secrets</I>,\n" +
               "<I>Harry Potter and the " +
               "Prisoner of Azkaban</I>,\n" +
               "<I>Harry Potter and the Goblet of Fire</I>, and\n" +
               "<I>Harry Potter and the "+
               "Order of the Phoenix</I>.\n",
             59.95)
      public static CatalogItem getItem(String itemID) {
        CatalogItem item;
        if (itemID == null) {
          return(null);
        for(int i=0; i<items.length; i++) {
          item = items;
    if (itemID.equals(item.getItemID())) {
    return(item);
    return(null);
    Using the above servlet and this one:
    package coreservlets
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class browser extends HttpServlet {
      public void doGet(HttpServletRequest request,
                        HttpServletResponse response)
          throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
         Connection conn = null;
         try{
             Class.forName("com.mysql.jdbc.Driver").newInstance();
         } catch(Exception e) {
             System.out.println(e);
         // connecting to database
         try{
             conn = DriverManager.getConnection
            ("jdbc:mysql://MY WEB ADDRESS FOR THE SQL TABLES GOES HERE");
              // System.out.println("Connection to database successful.");
           catch(SQLException se) {
             System.out.println(se);
         try{
              // Get the category from the input form
              String categoryString = request.getParameter("category");
              // check if no category
              if (categoryString == "") categoryString = "Action & Adventure";
             String selectSQL = "select title, director, rating, year_released, price, stock_count, image_name "+
                                "from video_recordings "+
                                "where category = '" + categoryString + "'";
             Statement stmt = conn.createStatement();
             ResultSet rs1 = stmt.executeQuery(selectSQL);
          // output html headers
          String title = "Films in the " + categoryString + " genre" ;
           out.println(ServletUtilities.headWithTitle(title) +
                    "><BODY BGCOLOR=\"#a00e0e\">\n" +
                  "<center><img src=\"http://localhost:8080/examples/pic.jpg\" width=350 height=200/></center>\n" +
                    "<H1 ALIGN=\"CENTER\">" + title + "</H1>\n");
           out.println("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
                    "<TR BGCOLOR=\"#FFAD00\">\n" +
                    "  <TH>Title\n" +
                    "  <TH>Director\n" +
                  "  <TH>Rating\n" +
                  "  <TH>Year Released\n" +
                  "  <TH>Price\n" +
                  "  <TH>Number in stock\n" +
                    "  <TH>image name"
    // Retrieve the results
             while(rs1.next()){
                  out.println("<TR>" +
                              "<TD>" + rs1.getString("title") + "</TD>" +
                              "<TD>" + rs1.getString("director") + "</TD>" +
                            "<TD>" + rs1.getString("rating") + "</TD>" +
                            "<TD>" + rs1.getDouble("year_released") + "</TD>" +
                            "<TD>" + rs1.getString("price") + "</TD>" +
                               "<TD>" + rs1.getString("stock_count") + "</TD>" +
                              "<TD>" + rs1.getString("image_name")  +"</TD>\n");
                             "<TD> <IMG SRC=\"../images/music/" + image_name +"\">"
        // close the html
        out.println("</TABLE></BODY></HTML>");
    // Close the stament and database connection
             stmt.close();
             conn.close();
         } catch(SQLException se) {
             System.out.println(se);
      }How do i merge these two together so that a catalogItem is created by connecting to the database and uses the select statement?? If any one can help me here i would be really grateful as i am having real trouble with this.

    Below is what i have come up with (I cut out the code that just gets in the way for this post, eg the connect to database and import statements) My problem is this would only work once has i need to add the item to the array addedItem in the first for loop, can anybody help me with this has i have tried a number of ways but can't get it to compile.
    private static CatalogItem[] addedItem
    private static CatalogItem[] ItemsInCat;
    CatalogItem item;
    CatalogItem details;
            int recordingidDB;
         String directorDB;
         String titleDB;
         String categoryDB;
         String imageDB;
         int durationDB;
         String ratingDB;
         String yearDB;
         float priceDB;
         int StockDB;
    // Create select statement and execute it
         try{
             String selectSQL = "select title, director, rating, year_released, price, stock_count, image_name "+
                                "from video_recordings " + "'";
             Statement stmt = conn.createStatement();
             ResultSet rs1 = stmt.executeQuery(selectSQL);
             while(rs1.next()){
              recordingidDB = rs1.getInt("recording_id");
              directorDB = rs1.getString("director");
              titleDB = rs1.getString("title");
              categoryDB = rs1.getString("category");
              imageDB = rs1.getString("image_name");
              durationDB = rs1.getInt("duration");
              ratingDB = rs1.getString("rating");
              yearDB = rs1.getString("year_released");
              priceDB = rs1.getFloat("price");
              stockDB = rs1.getInt("stock_count");
               item =
               new CatalogItem
                  (recordingidDB, directorDB,titleDB, categoryDB, imageDB, durationDB, ratingDB, yearDB, priceDB, stockDB);
         String title = "Catalog Items";
    out.println(ServletUtilities.headWithTitle(title) +
                    "<BODY BGCOLOR=\"#a00e0e\">\n" +
                  "<center><img src=\"http://localhost:8080/examples/img.jpg\" width=350 height=200/></center>\n" +
                    "<H1 ALIGN=\"CENTER\">" + title + "</H1>\n");
         // loop to go over each item in the array of catalogItem
             for  (int i=0; i < ItemsInCat.length; i++) {
               out.println("__________________________");
               details = item;
         if (details == null) {
    out.println("SORRY THERE HAS BEEN AN ERROR ");
         } else {       
    addedItem[] // needd to store item in array here
         out.println(titleDB + "\n" + priceDB + "\n");
         out.println("</BODY></HTML>");
         public static CatalogItem getItem(int recordingidDB) {
         CatalogItem item;
    for(int i=0; i<itemsInCat.length; i++) {
    item = itemsInCat[i];
    if (recordingidDB.equals(item.getItemID())) {
    return(item);
    return(null);
    // Close the stament and database connection

  • JD3.* could connecting Oracle database 5.05 but not new version

    Dear Sir,
    JD3.* could connecting Oracle database 8.05 but not new version of Oracle_Database at all(8I and 9I in OTN version), but could run on Borland JBuilder.
    Error message : IOException
    Could you tell me, help me too.
    steve chu
    (This week in Openworld and and email: [email protected])

    Steve -- My guess would be that you need to upgrade your JDBC drivers for your client program. They are downloadable from OTN. I expect that JBuilder has its own JDBC drivers which are newer than what you have and that is why it does not have a problem.
    Thanks -- Jeff

  • Brand new Mac user help please! How do you connect a 17" monitor to the MacBook? I have the monitor plugged into the Mac, but the F8 that I am used to with PC does not work. Please help. Thanks.

    Brand new Mac user help please! How do you connect a 17" monitor to the MacBook? I have the monitor plugged into the Mac, but the F8 that I am used to with PC does not work. Please help. I am getting lots of spelling errors as the MacBook laptop screen is too small. Thank you so much! .

    Contentmom6 wrote:
    Brand new Mac user help please! How do you connect a 17" monitor to the MacBook? I have the monitor plugged into the Mac, but the F8 that I am used to with PC does not work.
    Normally, you just connect the monitor to the MacBook using a VGA adaptor that you can buy from an Apple Store.  Now try System Preferences > Displays > Detect Displays.  You should now be able to select a display mode for the monitor.  If it still doesn't work, then I'd check that everything is properly connected.  I've had problems with colours disappearing due to a faulty connection in the VGA adaptor.
    Bob

  • Since my iphone 3g has changed to the new orange EE i cant get onto the app store it says cannot connect to itunes store can anyone help me fix it?

    Hi, since i upgraded my iphone to the latest IOS system last week, i have been on this new orange EE network, and since then i have been unable to get onto itunes and the app store, i keep getting the message "cannott connect to i tunes" can anyone help me figure out whats wrong with it?  Thanks

    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • Sorry/Help connecting to a new computer 'main'

    I'm sorry, i know this question has been asked many times before but after searching through pages worth of similar subjects i still have no concrete answer.
    My dad gave me his old iphone '3gs', he set this up for me on his computer. Now i have my own laptop and would like to set the partnership between the two, thus making controlling my device much simpler.
    My worry is not necessarily the music, i understand all the itunes only business. But my contacts, garage band saved songs, apps etc. What will happen to these when i sync? I've connected to the laptop, i always set my apple devices to manage music manually, but as i understand it everything will be wiped once i connected to a new 'main' controller/computer. It's the contacts, pictures and garage band saves that bother me.
    Please help, sorry to ask again....

    You'll have to use a 3rd party app to transfer ripped (non-purchased) music to your library as well as any pictures synced to your phone from the other computer.  Another option is to uses Home Sharing to import the music from the other iTunes library if it is on the same network (see http://support.apple.com/kb/HT3819).
    As far as you Garage Band tracks, I'm not sure about that since I don't use it.  It it's considered App data, that will be included in the backup (see http://support.apple.com/kb/HT4946).  Unless you can get a definitive answer on that play it safe and send them to your friend.

  • I Want to connect to database . plz help

    dear programmers
    i use forms9i and oracle database 9i under winxp. the database is on the local machine .
    to connect database from the form i do the following:
    1-choose file | connect from the main menue
    2-type scott/tiger then click on connect
    the following message appear
    ORA-12560 TNS :protocol adapter error.
    please i urgently need to connect to database
    please help

    dear Pamela Gamer
    I really thank u for helping me .
    I did the following :
    1- from Start menu,I select Programs > Oracle9i Developer Suite > Forms Developer > Start OC4J Instance. I waited till the window displays a message that OC4J has been initialized, and I minimized the window,and i did not close it.
    2-I opened my form and connected my database successfuly.
    3- when i started to run my form the same message appeared ( frm-10142: the http listener is not running on 127.0.0.1 at port 8888 . please start the listener or check your runtime perference)
    i do not know why it appeared again .i want to know what is the problem . in fact i hardly need to shift to forms9i, but this problem makes me disapointed.
    if you know the solution , please help me
    thank u again for helping me
    tarek

  • Connect Oracle Database with help of sql server storedprocedure

    Hii,
              Is there Any way to connect Oracle Database Using sql server storedprocedure.I want access oracle database and take some data and insert into my sql server database.so is there any way to connect in one
    stored procedure to connect oracle database and take some data and insert in to my sql server database.
    Nikunj Nandaniya

    Hello,
    I am getting below error when i kust Clic k on Test Connection in SSMS:
    TITLE: Microsoft SQL Server Management Studio
    The test connection to the linked server failed.
    ADDITIONAL INFORMATION:
    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
    Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "test".
    OLE DB provider "OraOLEDB.Oracle" for linked server "test" returned message "ORA-12154: TNS:could not resolve the connect identifier specified". (Microsoft SQL Server, Error: 7303)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.4000&EvtSrc=MSSQLServer&EvtID=7303&LinkId=20476
    BUTTONS:
    OK
    Can you please guide is there any other setting i need to do after install Oracle Client ?
    Best Regards,
    Tushar Malvi

  • TS1368 I can buy new apps but I can't update any - it says it can't connect to iTunes store! Please help!!!

    I can buy new apps but I can't update any - it says it can't connect to iTunes store! Please help!!!   I've tried the whole changing the date thing and that didn't work

    Try:
    Can't connect to the iTunes Store

  • I connected my brand new iPod Classic 160 GB to my brand new Sony home entertainment system through the headphone jack (to the audio line in). The volume is ridiculously low. Can somebody help me out here?

    I connected my brand new iPod Classic 160 GB to my brand new Sony home entertainment system through the headphone jack (to the audio line in). The volume is ridiculously low. Can somebody help me out here?

    Make sure the volume on the iPod is turned up fully, since this will affect what you hear through the stereo.
    Make sure Volume Limit is set to full. (From Main Menu, Settings/Volume Limit)
    If you purchased your iPod inside the EU (European Union), then the maximum volume from the headphone jack is lower than elsewhere in the world. If this is the case, buy yourself a 30-pin Dock Connector to 3.5mm jack lead, such as the one linked here...
    http://www.amazon.co.uk/Decrescent-Connector-Stereo-Auxiliary-iPhone/dp/B007NIE5 EE/ref=sr_1_1?ie=UTF8&qid=1386012456&sr=8-1&keywords=30+pin+to+3.5mm
    That connector will take a higher volume out (than the European Union's output) and that will be louder (and hopefully loud enough) through your stereo.

  • The account is invalid to access, please help me to connect to a new right email address. This is urgent for the pre-order, please respond as soon as possible.

    My email account is invalid to access, please help me to connect to a new right email address. This is urgent for the pre-order process, please respond as soon as possible.
    <Email Edited by Host>

    This is a user-to-user technical support forum. No one here can help you.
    Try
    https://expresslane.apple.com

  • Please help, probleme de connection to database oracle and  java

    Ihave a problem to make connection to database Oracle when I use a simple code of java
    ======================
    import java.sql.*;
    public class Exemple1 {
    public static void main (String args[]) {
    Statement stmt = null;
    Connection con=null;
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:GB","scott","tiger");
    catch (Exception e) { System.out.println(e);        }
    =================
    I have :
    * Linux (Fedora core3).
    * Oracle 10g
    My var. environ.:
    * ORACLE_HOME=/u01/app/oracle/product/10.1.0/Db_1
    * PATH=$ORACLE_HOME/bin
    * CLASSPATH=$ORACLE_HOME/jdbc/lib/ojdbc14.jar
    the error is:
    Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: oracle.sql.CharacterSet
    at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
    at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
    at JvResolvePoolEntry(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0)
    at oracle.jdbc.driver.DBConversion.DBConversion(short, short, short) (Unknown Source)
    at oracle.jdbc.driver.T4CConnection.connect(java.lang.String, java.util.Properties) (Unknown Source)
    at oracle.jdbc.driver.T4CConnection.logon() (Unknown Source)
    I don't know what's heppen exactly?

    If
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    is replaced
    with
    Class.forName("oracle.jdbc.driver.OracleDriver");does the java.lang.NoClassDefFoundError: while resolving class: oracle.sql.CharacterSet get generated?

Maybe you are looking for