Please help! I am new with Java

I wrote a program of this problem but it won't run. I don't know why please help me. Thank you very much and here the problem: Define a Java class named NumberCruncher that has a single double value as its only instance variable. Then define methods that perform the following operations on its number: get, double, triple, square, cube. Thanks for reading my problem.

class NumberCruncher {
double single;
public static void main(String[] args) {
single = 20.0;
System.out.println("single double" + single);
System.out.println("times two" + single*2);
//Bla Bla

Similar Messages

  • Please help! brand new to java - changing fonts

    i want to change the some of the font attributes on a label
    i tried doing it this way but it wouldn't work
    Label lblCompany = new Label("Reasonable Computers");
    Font myFont = new Font("Times New Roman", Font.Bold, 24);
    lblCompany.setFont(myFont);
    ^
    it tells me that there is an identifier expected at that point
    what i am doing wrong?

    I've had the same problem yesterday, and i thought it was a problem with java.
    But I tried to put this method call in some function (like the constructor) instead of putting it at the root of my class, and now it works fine.
    See if you don't call this method out of a function , maybe it's the same problem.
    Hope it can help !

  • Please help ... new to JAVA

    Hi All,
    I know this is stupid question. But I need help in learning Java. I have keen to learn this language. But I dont know how to approach this situation. You guys are expert please tell me which books will help me out and what is the best way to learn this langauge. I always get confused about so many pacakages in java.. Please help me.
    Thanx

    u need to study java books like thinking in java, java completer reference and Orelly books for java. They give more knowledge about java basics and then u can learn urself to the new technologies of java

  • Someone please help a complete beginner with Enterprise Manager!

    Question moved from
    Someone please help a complete beginner with Enterprise Manager!
    Please be gentle with me, I'm absolutely new to all this. We don't have a proper DBA and I've been tasked with the role. There is no-one else in the company with oracle experience and we don't have any support. Until now I've just used enterprise manager to manage the database, but now I have a problem..
    We are using Windows Server 2003 and Oracle 10g. I (stupidly) installed some network monitoring software on our server (PRTG network monitor). I almost immediately uninstalled it and all components/registry settings, but it seems to have thrown something out regards the OEM web interface.
    We used to access the OEM GUI through http://<hostname>:5500/em, but after installing/uninstalling the network monitor software the OEM webpage would only stay up for a few minutes, before saying 'Internet Explorer cannot display the webpage'. Restarting the DBconsole in services fixed the problem, but again, only for a few minutes.
    Spent all day yesterday looking at logfiles (they didn't make much sense to me), but seemed to be saying access was denied to the server ('actively denied it'). Lots of googling led me to believe I needed to reconfigure OEM by dropping and recreating it using:
    emctl stop dbconsole
    emca -deconfig dbcontrol db
    emca -repos recreate
    during this process I was asked for various passwords and a port number? I didn't even know what to use as the port number but guessed it was 5500 ?!? (probably wrong). As it didn't work I used the default port number that I found somewhere on the web.
    However now I am even deeper in the **** as this didn't work either, (some error about listnener?) and I have now lost the DBConsole in windows services. Obviously the OEM web console doesn't work at all now
    I would be eternally grateful for some patient, beginners help here..I can post whatever log files are necessary - I just need to know what I'm supposed to be doing and where to start..
    We used to log on to the OEM as 'SYSTEM', but nowhere in the process does it seem to ask me for the password for that (its asked me for SYS and SYSMAN)
    It could be that I'm going about this completely wrong, but with only a days experience in all this its pretty hard to know what I'm doing really!
    As you can tell I'm in way over my head..I just need OEM web interface to work!
    Thanks in advance

    ok, thanks to helpful comments from other people in my initial thread (posted in general database forum), after rebuilding the console/repository I now have EM up and running. But there are more problems..
    Firstly I have an error at the very top of the screen:
    java.lang.Exception: Number of responses does not match queries
    Also, the 'Host CPU' and 'Active Sessions' are blank and say 'No Data Is Currently Available' beneath them
    my emagent.trc file contains this error, repeating with different thread IDs every 30 seconds...
    (error = 10061)
    2012-04-30 17:19:28 Thread-4376 ERROR pingManager: nmepm_pingReposURL: Cannot connect to http://hostname:5500/em/upload/: retStatus=-1
    2012-04-30 17:19:59 Thread-1448 WARN http: snmehl_connect: connect failed to (hostname:5500): No connection could be made because the target machine actively refused it.
    Help!

  • I am having a problem with pop pups and small windows with ads constantly opening up on my safari?? Thought that macs didn't get virus? this looks like one- any experts around? please help me fix it with your instructions? really don't know what to do...

    Hi everyone,
    I am having a problem with my Mac OS X 10.7.5 mac book air , there are constant pop pups and small windows with ads blinking constantly opening up on my safari in front of everything?? it is constantly interupting me and makes me mistakingly click on it then another new windows open behind the one im using..
    I am not too sure if thats a virus or trojan.. I always thought that macs didn't get virus? this looks like one to me… any experts around? please help me fix it with your instructions? really don't know what to do... thanks

    Those are not viruses. You have probably installed some malware:
    The Safe Mac » Adware Removal Guide
    Helpful Links Regarding Malware Protection
    An excellent link to read is Tom Reed's Mac Malware Guide.
    Also, visit The XLab FAQs and read Detecting and avoiding malware and spyware.
    See these Apple articles:
              Mac OS X Snow Leopard and malware detection
              OS X Lion- Protect your Mac from malware
              OS X Mountain Lion- Protect your Mac from malware
              About file quarantine in OS X
    If you require anti-virus protection Thomas Reed recommends using Dr.Web Light from the App Store. It's free, and since it's from the App Store, it won't destabilize the system. If you prefer one of the better known commercial products, then Thomas recommends using Sophos.(Thank you to Thomas Reed for these recommendations.) If you already use Sophos, then be aware of this if you are using Mavericks: OS X Mavericks- Sophos Anti-Virus on-access scanner versions 8.0 - 9.1 may cause unexpected restarts
    From user Joe Bailey comes this equally useful advice:
    The facts are:
    1. There is no anti-malware software that can detect 100% of the malware out there.
    2. There is no anti-malware that can detect anything targeting the Mac because there
         is no Mac malware in the wild, and therefore, no "signatures" to detect.
    3. The very best way to prevent the most attacks is for you as the user to be aware that
         the most successful malware attacks rely on very sophisticated social engineering
         techniques preying on human avarice, ****, and fear.
    4. Internet popups saying the FBI, NSA, Microsoft, your ISP has detected malware on
        your computer is intended to entice you to install their malware thinking it is a
        protection against malware.
    5. Some of the anti-malware products on the market are worse than the malware
        from which they purport to protect you.
    6. Be cautious where you go on the internet.
    7. Only download anything from sites you know are safe.
    8. Avoid links you receive in email, always be suspicious even if you get something
        you think is from a friend, but you were not expecting.
    9. If there is any question in your mind, then assume it is malware.

  • I have an ipod 2g , The keyboard won't work! Or at least some of it's letters and numbers won't. please help i'm stuck with emojis

    i have an ippd touch 2g , a part of my keyboard won't work , i can type letters but i can't type numbers . please help i'm stuck with emojis keyboard

    Try restarting the iPod by holding down the lock and home button together and then slide the power button to turn it off and then wait 10 seconds and start it up again. If it is not a reset issue then it may be a hardware issue. Is your iPod damaged or have you dropped it recently? If it is a hardware problem then you may not be able to fix it. If your iPod has multitasking options like the new iOS devices, close out the app and then try again, it should reset your device to letters instead of emojis.

  • I created my itunes account YEARS ago!! And I can't remember the answers to my security questions? Because I cannot remember the answers I cannot make purchases in the app store. Please help me create new security questions.

    I created my itunes account YEARS ago!! And I can't remember the answers to my security questions? Because I cannot remember the answers I cannot make purchases in the app store. Please help me create new security questions. Please help me.

    If you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then you can try going to https://appleid.apple.com/and click 'Manage your Apple ID' on the right-hand side of that page and log into your account. Then click on 'Password and Security' on the left-hand side of that page and on the right-hand side you might see an option to send security question reset info to your rescue email address.
    If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then see if this user tip helps you get the questions reset :https://discussions.apple.com/docs/DOC-4551
    e.g. you can try contacting iTunes Support :http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management , and then try Apple ID Account Security
    or try ringing the number for Apple  in your country and ask to talk to the Account Security Team : http://support.apple.com/kb/HE57

  • HELP PLEASE HELP! urgent question with an easy answer!!!!

    Hello;
    I designed a JFrame game, that uses gif files as ImageIcons. The game works perfectly when I run it from console with the java.exe command.
    However; now I want to create a wraparound and run the JFrame in the Internet Explorer from an applet. So I created a new file that extends JApplet; this new file creates a new object of the JFrame-game's class and show()'s it.
    And I created an HTM file that runs the JApplet class. However, the internet explorer cannot open the applet because it has trouble loading the pictures (gif files). How can I load the pictures from my applet for my frame???
    I dont want to change the Java security file. I just want to make the images accessible by my applet. I cannot use commands like setImage in my applet because my JFrame sets the Images.
    (I repeat)My JApplet only invokes an object of my JFrame class and shows it.
    PLEASE HELP PLEASE PLEASE..
    Thanks..

    OK; let me tell you the whole thing. My pictures are in the same folder for sure.
    My JFrame reads pictures and assigns JButtons pictures. when I run the frame there are 16 buttons with the same picture, and when I click the buttons there is a listener in the JFrame that changes the pictures. Simply put, the JFrame has no trouble finding and loading the pictures.
    Then I created a JApplet as follows:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MemoryApplet extends JApplet
    public void init ()
         GameFrame ce = new GameFrame ();
         ce.show ();
    GameFrame is the name of the JFrame class. Then when I try to open the applet using IE, it gives the following error:
    Exception: java.security.AccessControlException: (javax.io.FilePermission back.gif read)
    back.gif is one of the gif files that are used in GameFrame

  • Please help...Problem with 3D Applet using JRE 1.5

    Hi all,
    I have an applet which uses sun opengl 1.3.1 plugin to render some 3D graphics. It is working fine with JRE 1.4.2_06, but not showing the 3D graphics with the latest JRE 1.5 release. I tried to repaint using available API with no success.
    Please help asap,
    Thanks in advance
    prasad

    I wonder if you have the same problem as me... Maybe we can find a solution for us both, no need for me to open a new thread for this topic then...
    I wrote an applet using Swing and compiled it using JavaSDK 1.4.x. I also installed the 1.4.x JRE for both of my test browsers. In Mozilla 1.1 the applet displays properly all the time. In IE6 SP1 it sometimes works as intended but sometimes the applet simply stops working, as per my Java Console somewhere after invoking the "start" method. Parts of the applet simply become gray and when I resize it - I have a JFrame in my applet - the whole JFrame becomes gray and does not respond to input nor it redraws itself. Shutting down IE does not close the JFrame(although the java console reports normal program termination and cleanup) and the only way to close it is through the task manager. I am using Windows 98SE btw.
    Does it sound similiar to your problem? It happens ONLY with IE, not with Mozilla. Anybody has an idea on what it could be? I doubt there's an error in my code...

  • Need help, I am terrible with Java, can someone help.

    Please can someone help me with this program. I am in a JAVA programming class and I am having a heck of a time. I am still having a problem with the basic concepts of JAVA but the teacher continues to give us difficult assignments with out any help. Here is the assignment:
    Write a class named 'Player' that has two attributes, 'name' (which has to be a 'Sting') and 'rating' (which has to be a 'int'). Then write an application class named "PlayerRating" that first creates an array consisting of 5 player objects, then display the list three times; first unsorted, then sorted by Name and finally sorted by rating.
    Must use the Bubble Sort Program and do NOT use Array.sort.
    Example output:
    Unsorted
    Name: Rating:
    Mickey Mantle 5
    Ty Cobb 3
    Babe Ruth 4
    Pete Rose 3
    Sammy Sosa 1
    Sorted by Name
    Name: Rating:
    Babe Ruth 4
    Mickey Mantle 5
    Pete Rose 3
    Sammy Sosa 1
    Ty Cobb 3
    Sorted by Rating
    Name: Rating:
    Sammy Sosa 1
    Pete Rose 3
    Ty Cobb 3
    Babe Ruth 4
    Mickey Mantle 5
    Here is what I have and it is not much, cause I am so lost:
    1 import java.io.*;
    2 import javax.swing.*;
    3 import java.text.*;
    4 import java.lang.*;//String[][];
    5 import java.util.*; //ArrayList;
    6
    7
    8 public class Player
    9 {
    10 public static void main (String [][]args)
    11 {
    12
    13 int maxSize = 100; //array size
    14 // String[][] s = new String[100][100]; //Default values: null
    15 boolean [] b = new boolean[4]; //default values: false
    16 int[][] i = new int[10][10]; //default values: 0
    17
    18
    19 PlayerRating arr; //reference to array
    20 //arr = new PlayerRating(maxSize);
    21 Sting player[]={"Mickey Mantle 5","Ty Cobb 3"
    22 ,"Babe Ruth 4","Pete Rose 3","Sammy Sosa 1"};
    23
    24
    25 }
    26 }
    Here is all I have on the second program:
    public class PlayerRating
    public void PlayerRating (int Max)
    int[][] i = new int[10][10];
    Please help I am totally lost.

    You repeat code, you should do a generic bubble sort with comparators, or declare class as Comparable. You can see how String class is Comparable, furthermore it has a final static Comparator for CASE_INTENSENSITIVE_ORDER.
    class User implements Comparable<User>{
      public static final java.util.Comparator<Cliente> RATING_COMPARATION=new java.util.Comparator<Cliente>(){
        public int compare(User u1,User u2){
               int comp=u1.rating-u2.rating;
               return comp==0?u1.name.compareTo(u2.name):comp;
         private String name;
         private int rating;
         public User(String name, int rating){
              setName(name);
              setRating(rating);
         public String getName(){
              return name;
         public void setName(String name){
              this.name = name;
         public int getRating(){
              return rating;
         public void setRating(int rating){
              this.rating = rating;
            // Compare users first by name and last by rating;
            public int compareTo(User anotherUser){
               int comp=name.compareTo(anotherUser.name);
               return comp==0?rating-anotherUser.rating:comp;
             public void equals(Object o){
              if(this==o)
                return true;
              if(o instanceof User){}
                 User anotherUser=(User)o;
                 return name.equals(anotherUser.name)&&rating==anotherUser.rating;
              return false;
               public int hashCode(){
                  return name.hashCode()+rating<<16;
    public class Sorting{
         public <E extends Comparable<E>>static void bubleSort(E[] arr){
              for(int i = 0; i < arr.length - 1; i++){
                   for(int j = arr.length - 1; j > i; j--){
                        if(arr[j].compareTo(arr[j - 1])<0)
                                     swap(arr,j,j-1);
         public static<E> void bubleSort(E[] arr,Comparator<E> cmp){
              for(int i = 0; i < arr.length - 1; i++){
                   for(int j = arr.length - 1; j > i; j--){
                        if(cmp.compare(arr[j],arr[j-1]) < 0)
                                      swap(arr,j,j-1);
            private static void swap(Object[] arr,int x,int y){
               Object tmp=arr[x];
               arr[x]=arr[y];
               arr[y]=tmp;
         public static void main(String[] args){
              User[] arr = new User[5];
              arr[0] = new User("Mickey Mantle", 5);
              arr[1] = new User("Ty Cobb", 3);
              arr[2] = new User("Babe Ruth", 4);
              arr[3] = new User("Pete Rose", 3);
              arr[4] = new User("Sammy Sosa", 1);
              System.out.println("Sorting by Name : ");
              bubleSort(arr)
              System.out.println(Arrays.toString(arr));
              System.out.println("Sorting by Rating : ");
              bubleSort(arr,User.RATING_COMPARATION);
              System.out.println(Arrays.toString(arr));
    }

  • PLEASE HELP me select new internal hard drive for Macbook Pro 2012 (non-retina)

    Good afternoon.
    I just bought a Macbook Pro 2012 (non-retina) 15 inch from a friend.  I think it is running Mountain Lion (has not been upgraded to Mavericks yet), and has iLife on it.  It came with the stock 500 gb 5400 rpm internal hard drive.  At home, I only have the Snow Leopard OS installation Cds and a copy of iLife 2011 installation Cds.  I am going to buy 16 gb of RAM from Other World Computing to install.
    I want to replace the hard drive with a 1 tb hard drive, preferably something that is $100 or less.
    I talked to Other World Computing (OWC) and looked at the Data Doubler Option to replace the optical drive with a Solid State drive, but decided that for now I want to keep the optical drive inside the computer for portability issues.
    I know that Solid State drives are better, but they are still too small, and I want the ease and portability of a 1 tb size INSIDE my computer.
    Initially I was going to order this from Other World Computing: 1.0TB 2.5" HGST Travelstar 7K1000 7200RPM SATA 6Gb/s 9.5mm Notebook Drive 32MB Cache. *'New' Factory Replacement with 2+ Year HGST Warranty*    As of April 4, 2014 it's on sale for $79
    But then I started reading some of the discussions online and thought maybe I should get a hybrid solid state drive?
    I saw on Amazon the Seagate 1TB Solid State Hybrid Drive SATA 6Gbps 64MB Cache 2.5-Inch ST1000LM014  It's on sale for $94.
    But according to some reviews, this Seagate has a platter that is only 5400rpm, unlike the previous Seagate Momentum that has a platter speed of 7200rpm.
    How reliable are the Seagate, versus a Toshiba or Western Digital or Hitachi or something else?
    Here are my questions about replacing the hard drive:
    1.  Is a hybrid solid state drive going to need some kind of special formatting after I put it into the macbook so that I can put the operating system on it?
    2.  Is a "normal" platter hard drive more reliable than a hybrid solid state drive?
    3.  Is there any additional driver or special software that I have to install for a hybrid solid state drive?
    4.  Currently there is no personal data stored on the computer.  Can I just put the new hard drive in, and then insert the snow leopard install cd?
    5.  If I install snow leopard, can I just go to the App store and get the free upgrade to Mavericks?
    6.  If I want to do the "Data Doubler" option in the future and add a normal Solid State drive into my computer, will it have trouble interacting with the 1 tb hybrid solid state drive?
    I would love to get some recommendations about the smartest option to upgrade my hard drive with something that will be fast (I edit lots of photos) and large (1 tb) that isn't going to cost too much.  I don't know much about the different brands or options (and there are so many listed in tons of online reviews), that I got really overwhelmed and confused by the info out there.
    I would really appreciate any help and advice.  I've never switched out a hard drive before.
    PLEASE HELP !!!  Thanks!
    Here is the "About this Mac" Info:
    Macbook Pro 15-in Mid 2012
    Model Identifier: MacBookPro9,1
    Processor: 2.3 GHz Intel Core i7
    Memory: 4 GB 1600 MHz DDR3
    Software: OS x 10.8.5
    Storage (Hard drive): APPLE HDD ST500LM012 Media, Rotational, SATA, GPT (GUID Partition Table)

    1.  Is a hybrid solid state drive going to need some kind of special formatting after I put it into the macbook so that I can put the operating system on it?
    The boot drive, regardless of what it is, needs to be formatted as Mac OS Extended (Journaled).  This is standard with OS X.
    2.  Is a "normal" platter hard drive more reliable than a hybrid solid state drive?
    There are arguments pro and con.  Bottom line, SSD's and hybrid drives are still quite expensive per GB than standard hard drives.  If you have the bucks and are a speed demon, go ahead.   I have better use for my money.   Standard hard drives are mechanical and may wear out over time.  But even though SSDs are not mechancial, they can still go bad and ultimately they even have a limit to their write capacity.  The jury is still out on this debate.
    3.  Is there any additional driver or special software that I have to install for a hybrid solid state drive?
    No
    4.  Currently there is no personal data stored on the computer.  Can I just put the new hard drive in, and then insert the snow leopard install cd?
    You can physically put the hard drive in but probably not install Snow Leopard on this MBP.
    The mid-2012 MacBookPro9,1 models came with Lion 10.7.3 (11D2097) preinstalled.   It is very unlikely you would be able to install Snow Leopard on it.  Historically you cannot install a version of OS X that is earlier than the version that came with your Mac (even if you replace the hard drive).
    5.  If I install snow leopard, can I just go to the App store and get the free upgrade to Mavericks?
    Not via Snow Leopard on this MBP.  See my response to #4.
    6.  If I want to do the "Data Doubler" option in the future and add a normal Solid State drive into my computer, will it have trouble interacting with the 1 tb hybrid solid state drive?
    No.  They are completely independent of each other; they are just independent storage units (drives) and their RAM does not interact.

  • Please Help,I made new account then remembered old one.need to delete new

    Please Please help . so complicated . ok i had an apple id but couldn't remember id n password so i made a new one . old one has all my music . old one has an old email that i can't access . after i made new one i remembered the old one . i want the old one cause it has alot of purchased music on it . thing is , my current email is now assosiated with new id . cant use same id with both so i need to delete new account so i can add my email to old account . How in the world do I delete the new apple id ? Please help me

    This is a user-to-user forum. Nobody here can delete anything for you.
    But - even if you contacted apple/itunes, I don't think they will delete it, either. Just don't use the new one, is my advice. It's a huge hassle over the years to have to remember the login credentials for 2 accounts.

  • Please help this clueless beginner with out.print syntax....

    Please help a clueless beginner out!!!! :-)
    I'm trying to build a dynamic table that functions as a calendar...(see http://www.oreilly.com/catalog/javacook/chapter/ch18.html for the basic idea and code structure).
    Here's the problem...I want to make each date inside of the table a hyperlink to a new page. I figured out how to create the hyperlinks, but I CAN'T figure out how to create hyperlinks that pass variables to a new page.
    Here's the code that works:
    // Fill in numbers for the day of month.
    for (int i = 1; i <= daysInMonth; i++)
    out.print("<td>");
    out.print("<a href=newpage.jsp>");
    out.print(i);
    out.print("</a>");
    out.print("</td>");
    Here's the code that DOESN'T work....but can serve as pseudo-code for what I want to do:
    // Fill in numbers for the day of month.
    for (int i = 1; i <= daysInMonth; i++)
    out.print("<td>");
    out.print("<a href=newpage.jsp?year=<%= yy %>&month=<%= months[mm] %>&date=<%= i %>>");
    out.print(i);
    out.print("</a>");
    out.print("</td>");
    <%= yy %>, <%= months[mm] %> are defined elsewhere in the code, and I want to use the current value of "i" from the loop.
    So, if everything works like I want, the table will get created, and if yy=2002 and mm=January, then the hyperlinks will look like:
    for day 1:
    "/newpage.jsp?year=2002&month=January&date=1"
    for day 2:
    "/newpage.jsp?year=2002&month=January&date=2"
    ...for day 31:
    "/newpage.jsp?year=2002&month=January&date=31"
    Can someone please point me in the right direction? Is it even possible to do what I want? (I assume it is...but maybe I can't use out.print???)
    Thanks!

    Hi. The expression "<%=some_Java_expression %>" is the JSP tag, that returns string value to HTML code. You should use it in HTML block like:
    <%String myname="Ivan"; %>
    <body>
    <p>My name is: <%=myname %></p>
    But You tried to use it inside the string expression and it generated some code like this:
    <a href="newpage.jsp?year=<%=yy%">...
    , didn't it?
    It invokes method out.print(" ... "), that prints this string value (but in the HTML block). So You tried to print something inside the print method. You should rewrite Your code like this:
    for (int i = 1; i <= daysInMonth; i++)
    out.print("<td>");
    out.print("<a href=newpage.jsp?year="+yy+"&month="+months[mm]+"&date="+i+">");
    out.print(i);
    out.print("</a>");
    out.print("</td>");
    I used the + operator to join Your code for link tag with the values (yy, months[mm], i.
    I hope it helps You,
    bye.</a>

  • Please help me get started with Databases...

    I've spent all day moving from one tutorial to the other trying to figure out how to use a Database with Java. I haven't found anything that explained things basic enough for me to understand, however, I did download and install MDAC 2.8 which was suggested in on one of the sites and I also have MS Access to work with for creating the database. Can somebody please explain what I need to do in order to access a database from my program in simple, easy to follow, steps?
    Also I have a small question about .requestFocus();In my program I have a Radio button called Format1 and a text area called textArea. I set Format1 to be selected using the following code: Format1.setSelected(true); and I attempted to make the cursor start inside the text area with: textArea.requestFocus(); Currently, when I start the program, Format1 has the focus instead of textArea. How can I make the cursor start at the end of the text inside of textArea everytime I start my program?

    Try this:
    package be;
    import java.sql.*;
    import java.util.*;
    public class DataConnection
        public static final String DEFAULT_DRIVER   = "sun.jdbc.odbc.JdbcOdbcDriver";
        public static final String DEFAULT_URL      = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=e:\\Project\\Database.mdb";
        public static final String DEFAULT_USERNAME = "admin";
        public static final String DEFAULT_PASSWORD = "";
        /** Database connection */
        private Connection connection;
         * Driver for the DataConnection
         * @param command line arguments
         * <ol start='0'>
         * <li>SQL query string</li>
         * <li>JDBC driver class</li>
         * <li>database URL</li>
         * <li>username</li>
         * <li>password</li>
         * </ol>
        public static void main(String [] args)
            DataConnection db = null;
            try
                if (args.length > 0)
                    String sql      = args[0];
                    String driver   = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
                    String url      = ((args.length > 2) ? args[2] : DEFAULT_URL);
                    String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
                    String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
                    db = new DataConnection(driver, url, username, password);
                    List result = db.query(sql);
                    System.out.println(result);
                else
                    System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
            catch (SQLException e)
                System.err.println("SQL error: " + e.getErrorCode());
                System.err.println("SQL state: " + e.getSQLState());
                e.printStackTrace(System.err);
            catch (Exception e)
                e.printStackTrace(System.err);
            finally
                if (db != null)
                    db.close();
                db = null;
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection() throws SQLException,ClassNotFoundException
            this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
         * Create a DataConnection
         * @throws SQLException if the database connection fails
         * @throws ClassNotFoundException if the driver class can't be loaded
        public DataConnection(final String driver,
                              final String url,
                              final String username,
                              final String password)
            throws SQLException,ClassNotFoundException
            Class.forName(driver);
            this.connection = DriverManager.getConnection(url, username, password);
         * Clean up the connection
        public void close()
            try
                this.connection.close();
            catch (Exception e)
                ; // do nothing; you've done your best
         * Execute an SQL query
         * @param SQL query to execute
         * @returns list of row values
         * @throws SQLException if the query fails
        public List query(final String sql) throws SQLException
            Statement statement     = this.connection.createStatement();
            ResultSet rs            = statement.executeQuery(sql);
            ResultSetMetaData meta  = rs.getMetaData();
            int numColumns          = meta.getColumnCount();
            List rows               = new ArrayList();
            while (rs.next())
                Map thisRow = new LinkedHashMap();
                for (int i = 1; i <= numColumns; ++i)
                    String columnName   = meta.getColumnName(i);
                    Object value        = rs.getObject(columnName);
                    thisRow.put(columnName, value);
                rows.add(thisRow);
            rs.close();
            statement.close();
            return rows;
    }Solve one problem at a time. Get the database going, then worry about how you'll present it to the users. - MOD

  • Please Help!  Two problems with my iMac at once a week b/4 finals!!!!

    First I'd just like to mention that I have no idea which OS X I have so...yeah, sorry. I was depending on this computer to work for my class finals. Anyway, on with the problems.
    My school is getting all new computers next year, so they are selling all of their iMacs for ten dollars each. Like an idiot, I bought one. And...so did my brother. But anyway, I got it home and started it up and all that came up was the traditional BIIINNNNGGGG, a white screen(for a second), then a gray one. This little icon comes up in the middle that you can't click on(the cursor doesn't come up)but it's purple and has a little cartoon face on it. This icon only comes up if you are not pressing any keys or click/moving the mouse.
    So I went back to school the next day and asked what was up, and they said that they completely wiped the computer and that I would have to buy new OS X install software. Okay...so I went to my computer teacher and he had a few sets of OS X install software.
    I brought it home and turned on my computer. I put in the disk that said OS X Install and it went in. The computer whirred for a bit, then spit the disk back out. So I decided to try a different disk because I thought that maybe the computer already had the contents of that disk on it. I put in the Applications disk, and now it refuses to come out. I have tried plugging the keyboard into different ports(there are two, with two others on the keyboard itself for the mouse) and everything. I looked inside through the little slot(discs go right into the computer-no hard drive or disk tray that slides out) on the front and the disc is spinning but nothing is happening.
    Please help me with both my wiped computer problem and my stuck disc problem. I have tried to give as much detail to help anyone who can help me. Please, WHAT CAN I DO?!
    iMac   Mac OS X (10.0.x)   I have an OS X. No idea which one...
    iMac   Mac OS X (10.0.x)   I have an OS X. No idea which one...
    iMac   Mac OS X (10.0.x)   I have an OS X. No idea which one...

    The full retail install disks are available here and at any Apple Store and many computer retailers. Also, check the system requirements. Be sure your Mac has firewire and enough ram to run Tiger. At this point you might be able to find the disks at a slightly discounted price because of the coming release of 10.5 Leopard. But be sure it is the black disk, boxed version if possible.
    EDIT: And the install disc for Tiger is a DVD, so be sure your iMac has DVD.
    This may help to narrow down the model iMac you have.
    -mj
    [email protected]
    Message was edited by: macjack

Maybe you are looking for

  • Error while creating a new BPEL project

    Hello! When I create a new BPEL project, I get this message: "Object expected", and on the footnotes, the following message is printed: "event://LogErrorEvent?bpelz.html trapped at 62: object expected"... Does anybody knows what is happening? Thanks

  • Why does text box move when I open pages doc on my friend's mac?

    Hi Everyone,   So I have this very vexing problem with pages. I have been trying to collaborate with a friend of mine and everytime the pages document moves from one computer to the other the text boxes move terribly out of place. So for example, I w

  • Data Services as a data migration tool

    Hello All, Has anybody used Data Services as a data migrition tool from a SAP ECC system?  If so what is it like to use and are there any documents on this? Cheers, Nick.

  • Palm treo 750 os required

    i have a palm treo 750 unlocked  recently i updated it to windows mobile 6.5  and i am in problems with it i want to reset it to wm6 pl send me the original os link

  • Permissions problem in Time Machine

    I need to restore my iPhoto Library which I've somehow messed up today. I renamed the damaged library to Old_iPhoto Library then went into TM and selected the last backup from yesterday but the iPhoto Library will not restore. It starts to copy but t