I'M NEW TO THIS, i hope someone can help me out with something so simple...

Hello all
i'm a first time user with java...my editor is Visual J++ (trial ed)...i'm testing out java to see if i want to use this for my company. for the past 4 days i've been trying to figure out how to connect to a database (i'm using MS SQL SERVER 2K) i've already posted in the JDBC Fourm...but found no answer...I apologize if I'm posting in 2 different forums at same time...but you gotta feel me on this, over 4 days on just trying to connect is not healthy LOL....
I already downloaded the driver from MS. Installed it followed the user guide (acrobat pdf file) on how to implement it...but i'm still stuck and haven't reached no where....what i want to do is a simple select statement but i can't do that without connecting first....maybe one of you out there has a sample code who uses MS SQL SERVER 2K...or someone can just be a miracle and help out on my code....the code will be attached below
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class AccessApp extends Frame
     TextField driver = new TextField(80);
     TextField url = new TextField(80);
     TextField sql = new TextField(80);
     Button doIt = new Button("Do it!");
     TextArea resultArea = new TextArea(10,60);
     public static void main(String args[])
          AccessApp app = new AccessApp();
     public AccessApp()
          super("AccessApp");
          setup();
          pack();
          addWindowListener(new WindowEventHandler());
          show();
     void setup()
          setupMenuBar();
          setLayout(new GridLayout(2,1));
          Panel topPanel = new Panel();
          topPanel.setLayout(new GridLayout(4,1));
          Panel panels[]=new Panel[4];
          for(int i=0;i<panels.length;++i)
               panels=new Panel();
               panels[i].setLayout(new FlowLayout(FlowLayout.LEFT));
          panels[0].add(new Label("Driver:"));
          panels[0].add(driver);
          panels[1].add(new Label("URL: "));
          panels[1].add(url);
          panels[2].add(new Label("SQL: "));
          panels[2].add(sql);
          doIt.addActionListener(new ButtonHandler());
          panels[3].add(doIt);
          for(int i=0; i<panels.length; ++i)
               topPanel.add(panels[i]);
          add(topPanel);
          add(resultArea);
     void setupMenuBar()
          MenuBar menuBar = new MenuBar();
          Menu fileMenu = new Menu("File");
          MenuItem fileExit = new MenuItem("Exit");
          fileExit.addActionListener(new MenuItemHandler());
          fileMenu.add(fileExit);
          menuBar.add(fileMenu);
          setMenuBar(menuBar);
     void accessDB()
          try
               Class.forName(driver.getText()).newInstance();
               Connection connection=DriverManager.getConnection(url.getText());
               Statement statement = connection.createStatement();
               boolean hasResults = statement.execute(sql.getText());
               if(hasResults)
                    ResultSet result = statement.getResultSet();
                    if(result!=null) displayResults(result);
               else resultArea.setText("");
               connection.close();
          catch(Exception ex)
               resultArea.setText(ex.toString());
     void displayResults(ResultSet r) throws SQLException
          ResultSetMetaData rmeta = r.getMetaData();
          int numColumns=rmeta.getColumnCount();
          String text="";
          for(int i=1; i<=numColumns; ++i)
               if(i<numColumns)
                    text+=rmeta.getColumnName(i)+" | ";
               else
                    text+=rmeta.getColumnName(i);
          text+="\n";
          while(r.next())
               for(int i=1;i<=numColumns;++i)
                    if(i<numColumns)
                         text+=r.getString(i)+" | ";
                    else
                         text+=r.getString(i).trim();
               text+="\n";
          resultArea.setText(text);
     class ButtonHandler implements ActionListener
          public void actionPerformed(ActionEvent ev)
               String s=ev.getActionCommand();
               if(s=="Do it!") accessDB();
     class MenuItemHandler implements ActionListener
          public void actionPerformed(ActionEvent ev)
               String s=ev.getActionCommand();
               if(s=="Exit")
                    System.exit(0);
     class WindowEventHandler extends WindowAdapter
          public void windowClosing(WindowEvent e)
               System.exit(0);
I hope this helps
and hopefully someone will respond

First use JPanel not Panel.
Panel panels[]=new Panel[4];becomes
JPanel panels[]=new JPanel[4];Then refactor your code so that you use arrays correctly:
panels=new Panel();
panels.setLayout(new FlowLayout(FlowLayout.LEFT));becomes
panels=new JPanel();
panels[i].setLayout(new FlowLayout(FlowLayout.LEFT));
I did the above changes to your code and it worked fine.
Dave

Similar Messages

  • I have several issues that I hope you can help me out with. I am a professional photographer with a Mac with OS X 10.9.4: - I can only make ONE contact sheet in CS6 (from AUTOMATE) from pictures indicated in Bridge. If I want to make another contact sheet

    I have several issues that I hope you can help me out with. I am a professional photographer with a Mac with OS X 10.9.4:
    - I can only make ONE contact sheet in CS6 (from AUTOMATE) from pictures indicated in Bridge. If I want to make another contact sheet I need to shut down and restart CS6.
    - Camera RAW: if I change any setting in Camera RAW (except exposure), having first optimized the exposure, the exposure will automatically return to zero. Sometimes when I've set exposure and cropped the picture in Camera RAW Plug-In, the effects are lost just by opening the picture in CS6.
    - Sometimes if I crop a picture in Camera RAW, it may be impossible to open it again from Bridge!
    - I cannot do lens corrections in Camera RAW, at all. The Camera RAW comment is that "it cannot load the correct lens type". Why?

    Are you writing that when you select  a large number of images in the bridge  like a hundred thumbnails  when you then use Bridge menu Tools>Photoshop>Contact Sheet II that Photoshop only produces a single contact sheet for the first few thumbnails and fails to produce additional contact sheets for the other selected thumbnails? Photoshop contact sheet II script should create as many contact sheet as needed  for the numbers of thumbnails selected.  Perhaps the script is hung or you have exhausted  your machine resources.
    ACR Crop tool does not crop the RAW file it records crop settings to be used during the conversion process.    Camera RAW DATA is not altered.  The only changes made to RAW Files is ACR Metadata may be added.  Anything you do in ACR can be un-done in ACR.    If you can not open a RAW File in ACR the Files is either corrupt or from a new camera ACR does not support yet.  ACR should not corrupt RAW files.
    If you do not have a lens profile for ACR I think you should still be able to do lens correction manually in ACR.
    Some of what you write I don't follow could you post some screen captures of your problems often a picture helps.

  • Im new to java and hope somebody can help me with my question

    Hi!
    Im quite new to java and I just have some simple questions..
    can someone please tell what kinds of error are considered as language violation for java? where can I find more info about these errors?
    can someone give me a simple example on a kind of error that cannot be caught in both compilation and runtime? I hope someone can help me out. Thanks in advance!!

    knightz211 wrote:
    Im just asking about errors that might go against the language definition but cant be detected.. If it "goes against the language defintion," it will be detected by the compiler. That's half of the compiler's job is to tell you what you've done that violates the language spec.
    because it confuses me when they say that such errors might occur so I just want to know what might these errors be.. sorry for that..Who's "they"? What exactly* did "they" say about "such errors"? It sounds to me like you're just confused, and you think there's something mysterious and inexplicable going on but you don't know what and don't even know what you're asking.
    I would suggest not worrying about hypothetical problems that you can't even put into words and focussing on learning Java. Along the way, if you encounter real, specific, actual problems, ask about them, and you'll probably get answers about the problems themselves and the language or theory behind them.

  • Hi, I hope someone can help.... When I open a new user account, which I want to set parental control on, the screen keeps freezing once the account is open. The wee rainbow circle appears and I can't do anything. Does anyone know how to fix this? Thanks

    Hi, I hope someone can help.... When I open a new user account, which I want to set parental control on, the screen keeps freezing once the account is open. The wee rainbow circle appears and I can't do anything. Does anyone know how to fix this? Thanks

    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at the top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    Report any errors it found for Disk Repair, don't need the ones for Permissions Repair.
    Try it again & see if anything changed, but have Activity Monitor open & Show All Processes & sorted on CPU%, also have Console open if we can... maybe not when switching, but we'll see.
    Does this happen if you just try to create a new admin user???

  • Hope someone can help - Lightroom not working...at all...nothing....

    I have tried installing about 20 or so times now and still cant get any thing at all when i launch the application - its likek it freezes. Something somewhere is missing or corrupt in my mac or the dowmload i downloaded and here's really hoping someone can help.
    I have been using the beta since beta 1. This morning i downloaded the V1.0 and went through the usual steps on a mac. Launched the programme and got the option screen of entering a code or trying for free for 30 days.
    Chose the free trial as my serial code had not yet been sent.
    The application seemed to start and then said it was going to upgrade/update (or similar) my old library and this may take a few minutes. Fine - I've got all day - no worries.
    5 hours later and not a whole lot appears to have happened other than Lightroom being frozen and I cant do much. Force quit ensues and an attempt to relaunch the application.
    It launches and I getthe start up Window that lists all teh people who made it...but my cursor just goes into spinning ball mode an dnothing happens. This has now gone on about 20 or so times. I have tried removing the Lightroom with Appzapper and then re-installing the original beta followed by the new download....still nothing but a frozen lightroom
    Anyone got any ideas - it must be something to do with my mac as everyone else seems to be using lightroom ok... and i'm desperate...seeing as i've been using it since beta 1
    hope someone can help??

    Another thing to check is the permission settings on the Lightroom application and on the folder where your library lives (or will live, if you're making a new one.)
    The Lightroom application needs to have an owner who has read/write permission on the library folder's location. Normally this owner will either be your own user ID or the "system" ID -- check by doing a command-i and seeing what shows up under the 'Details' section of the 'Ownership and Permissions' section.
    I was having exactly the same problem you described until I checked and discovered that for some reason, Adobe's Installer had installed Lightroom with a strange owner ID that only had read permission on my library folder's location. Since Lightroom needs to be able to both read and write to the library when it starts up, it was launching and then just sitting there doing nothing.
    I changed Lightroom's owner to 'system,' then made sure that the 'admin' group (of which 'system' is a member) had read/write permission on my library folder's location. After that, Lightroom launched fine.

  • Hi, I have a large number of products in one column and prices of the products in another. Most prices are different. I want to know if it is possible to increase all of the prices by 5% or 10% etc. Hope someone can help. From Stiffy

    Hi, This is my first time I hope someone can help.
    I am working with numbers and I have a large number of products in one column and the relevent prices in another. All the prices are different and I want to increase the price of everything by 5% or 10% etc. Is this possible?
    Thanks in advance
    Stiffy123

    Ad a new, temporary column (or one you can hide when not using). Let's say the current Prices are in column C and the new column is D.
    you can inflate the prices in column C by 5% by entering the formula in the first cell of column D as:
    =C2*105%
    likes this:
    to fill down, select D2, then copy, then select the D3 thru the end of the column, then paste.  Now select C2 thru the end of column C, now paste over the existing values using the menu item "Edit > Paste Values"
    you can now hide column D until you need to use it again.

  • HI       I HOPE SOMEONE CAN HELP ME  Thanks to all

    HI I HOPE SOMEONE CAN HELP ME
    I have put the structure of the XML and the code that I am trying to use as well as the error I am getting
    I am trying to get to a Node in a XML file.
    What I am needing to do is to put the FIRST_NAME + LAST_NAME into a Combo box so the user can select their name .
    I also have this code, but get this error
    "Configuration.java": getNodeValue() in org.w3c.dom.Node cannot be applied to (java.lang.String) at line 902, column 35
    Thanks to anyone that can Help
    Craig
            try {
              Node userNode = xmlDoc.getNode(
                  "/EPOD_USER/USER_CONFIGURATION/USER_INFOMATION/ALL_USERS/");
              userXmlDoc = new XMLDoc("ALL_USERS");
              userXmlDoc.copyChildNodesToDoc(userNode);
              NodeList userNodeList = userXmlDoc.getNode("ALL_USERS").getChildNodes();
              System.out.println("Node List    " + userNodeList);
              UserNmaejComboBox.removeAllItems();
              userNodeHashtable.clear();
              for (int index = 0; index < userNodeList.getLength(); index++) {
                Element element = (Element) userNodeList.item(index);
                String Testing = element.getNodeValue("FIRST_NAME");
    //This is where I get this error
    //     "Configuration.java": getNodeValue() in org.w3c.dom.Node cannot be applied to (java.lang.String) at         line 902, column 35
                String userName = "User" + element.getAttribute("index");
                UserNmaejComboBox.addItem(Testing);
                userNodeHashtable.put(userName, (Node) element);
              if (UserNmaejComboBox.getItemCount() > 0) {
                UserNmaejComboBox.setSelectedIndex(0);
            catch (NodeNotFoundException nnfe) {}
            catch (IllegalNodeAddException inae) {
              System.out.println(inae.getMessage());
             saveEpod();
          }This is the structure of the XML
    - <USER_INFOMATION>
    - <ALL_USERS>
    - <USERS index="1">
    <TITLE>Miss</TITLE>
    <FIRST_NAME>z</FIRST_NAME>
    <MIDDLE_NAME>z</MIDDLE_NAME>
    <LAST_NAME>z</LAST_NAME>
    <EMAIL>z</EMAIL>
    <MOBILE>z</MOBILE>
    </USERS>
    - <USERS index="2">
    <TITLE>Mrs</TITLE>
    <FIRST_NAME>l</FIRST_NAME>
    <MIDDLE_NAME>l</MIDDLE_NAME>
    <LAST_NAME>l</LAST_NAME>
    <EMAIL>l</EMAIL>
    <MOBILE>l</MOBILE>
    </USERS>
    - <USERS index="3">
    <TITLE>Mr</TITLE>
    <FIRST_NAME>Craig</FIRST_NAME>
    <MIDDLE_NAME />
    <LAST_NAME>Laird</LAST_NAME>
    <EMAIL />
    <MOBILE />
    </USERS>
    - <USERS index="4">
    <TITLE>Miss</TITLE>
    <FIRST_NAME>Jackie</FIRST_NAME>
    <MIDDLE_NAME />
    <LAST_NAME>Laird</LAST_NAME>
    <EMAIL />
    <MOBILE />
    </USERS>
    </ALL_USERS>
    </USER_INFOMATION>

    If you look at the API docs, you'll see that getNodeValue takes no args. If I'm not mistaken, you need to get the text node that is the child of the <FIRST_NAME> element node and call getNodeValue on it.

  • Hi guys I hope someone can help me

    Hi guys I hope someone can help me I have a problem with Apple compressor 4. Everytime I use Apple clusters it works for the first time. And when I try to use it again it disappears. I have to delete the program and reinstalled it and then I can activate the clusters again does anyone know why this happens.

    There was just an extensive discussion about clusters here. See if there is anything helpful it that may apply to you.
    Open up Qmaster from the Compressor menu toolbar. Post screen shots of the Setup window and Advanced window.
    Russ

  • I have 2 problems I hope someone can help me with.

    As the title says, I problems I hope someone can help me with as I don't know who else to ask for this.
    1. I tried to pre-order Dying Light for the Xbox One and during checkout the system cancelled my order saying that the store stock had been spoken for. However, I went in once the game released to the same store and was able to purchase the game no problem so in effect I just missed out on my $10 pre-order certificate.I wanted to pre-order but it wouldn't let me - I have never seen this error before.
    2. I took advantage of the $39.99 12+1 month Xbox Live Gold gift card you had on sale yesterday. Only the Halo one was abailable at my local store so I ordered 2 of those for pickup. I got home and used the cards and it was only for 12 months not 12+1 as it still says on the website here:
    http://www.bestbuy.com/site/searchpage.jsp?st=3878002,+8972116&_dyncharset=UTF-8&id=pcat17071&type=p...
    Is there a way to get the extra month advertized?
    Thank you!
    Solved!
    Go to Solution.

    Hello also_nadrag,
    Thanks for writing in, and thanks too for being a My Best Buy member.  We appreciate your loyalty.  I'll be happy to talk to you about your recent online experiences.
    From the sound of things you may have waited too long to attempt a pre-order for in-store pickup for Dying Light.  As the order was not able to be processed, I'm afraid we will not be issuing the $10 certificate.
    The product description on the Xbox Live Halo card is incorrect in labeling this item as including 1 extra month.  As the image online and packaging indicates, this card has an extra bonus for Halo: The Master Chief Collection.  We have reported the description error and I hope it is corrected soon.  I am sorry for any confusion this may have caused.
    Please visit us any time with questions or concerns.
    Sincerely,
    Mike|Social Media Specialist | Best Buy® Corporate
     Private Message

  • My iPod 5 screen is black the camera will make the clicking sound when pushing the home button and sleep button at the same time but the s teen stays black !! I hope someone can help

    I have an iPod 5.  The screen is black, I tried charging it.  It makes a bing when I plug it in so power is going to it.  When I hold the sleep button and home button to use the camera it takes a pic although the screen stays black the sound is there.  I hope someone can help me !!!

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • My trash bin has one item that refuses to be deleted. Under name, it says, 0. date; dec. 31, 1903. size; 0 kb. I have no idea where it came from. When I click, info. the info. window starts to appear, then goes away. Weird or what? Hope someone can help?

    my trash bin has one item that refuses to be deleted. Under name, it says, 0. date; dec. 31, 1903. size; 0 kb. I have no idea where it came from. When I click, info. the info. window starts to appear, then goes away. Weird or what? Hope someone can help?

    sorry i forgot that... i use php5 so i guessed at the module name... upon looking closer at the conf its mod_php4.c
    <pre>
    <IfModule mod_php4.c>
    AddType application/x-httpd-php .php
    </IfModule>
    </pre>

  • Hi there Hope someone can help me here. I am currently on holidays and my Kids have disabled my iPad so I now have to sync with my computer. I don't have my computer handy and want to use my device over the next few weeks if possible so can anyone help me

    Hi there
    Hope someone can help me here. I am currently on holidays and my
    Kids have disabled my iPad so I now have to sync with my computer.
    I don't have my computer handy and want to use my device over the next few weeks
    if possible so can anyone help me please
    Thanks
    Darren
    iPad 2 Wi-Fi + 3G, iOS 6.0.2

    You need a computer.
    Suggest you goto the nearest Apple Reseller and ask them to help you.

  • I can't use my license key Flash Builder 4.5 with this release. Someone can help me ?

    I can't use my license key Flash Builder 4.5 with this release. Someone can help me ?

    Hi,
    Flash Builder 4.5 serial number will not work directy in Flash Builder 4.7. You can use FB 4.5 key in upgrade scenario (upgradation from FB 4.5 to FB 4.7).
    Please use the Flash Builder 4.7 serial number provided at http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_flashbuilder4-7  for serialing Flash Builder 4.7.
    -Mugdha

  • HT4597 Can I have 2 accounts on my iPhone.  I have 2 on my computer and have a signal that 1 email is in my inbox.  It is an iCloud message but I can't access it.  Hope someone can help.  Thanks,  Lorna

    Can I have 2 accounts on my iPhone.  I have 2 on my computer and have a signal that 1 email is in my inbox.  It is an iCloud message but I can't access it.  Hope someone can help.  Thanks,  Lorna

    You can only have one active iCloud account and one iTunes account.  Are you by chance refering to email accounts defined in the mail app?  If so, if one of the accounts (a non-iCloud account) is a POP account, then an email is usually sent to one device.  Once sent, the email is deleted from the server, thus other devices never get copies.  That's how POP works.

  • I have the ipad3,and I plug my charger in to charge my ipad and it comes up with the charging battery sign charges for a few minuets and then the white apple sign loads up into the screen then my ipad goes dead again,I hope someone can help:)

    I have an ipad 3, when I plug my charger in the ipad comes up with the sign to say it is charging and then the apple sign loads up as if the ipad is about to come on,but then the ipad just goes dead again,I've tried holding both buttons down and I have also tried charging it over night but still nothing is working.
    I hope someone could help:)

    When you say you tried holding both buttons, did you mean you held both the power and home buttons until the apple logo appeared, ignoring the red slider if that appears?  If so, exactly what happens?
    You may need to take the iPad and charger to an Apple store genius bar to be tested by the techicians.

Maybe you are looking for

  • Generate lowercase XML tags

    Hi, In my PL/SQL procedures, I generate XML files based on SQL queries, like this: SELECT XMLELEMENT ("web_vpreparations", XMLAGG( XMLELEMENT ("web_vpreparation", XMLFOREST (CODE as "code", COMMERCIAL_NAME as "commercial_name", As you can see, I rena

  • How can i update my Mac OS X software?

    before i start im the newbiest newbie with macs. Im currently Using a powermac G4 with 10.5.8 I've tried installing programs like Google Chrome and Spotify but when i put them in the applications folder theres a crossed circle over it and wont let me

  • Mail deception - says messages are sent out but are not delivered

    The Mail program appears to send my outgoing e-mail messages but does not actually do so. When I send a new message or reply to a message, Mail behaves as though the message has been sent: the spinner runs and the swoosh sound occurs when the message

  • I can't see website, others can

    Hi All Today I purchased a domain name from dotster.com; and set up forwarding to my .mac account. Within the hour everything was working just fine...I could enter the url: www.robertdelaneyarts.com I could navigate through the site and everything wa

  • Select does not recognizes subelement/nodes in xml

    Problem: Querying(or update) xml using xpath recognizes only the root node, and ignores all of the subnodes. What was done: 1. I created and registered xml schema using dbms_xmlschema 2. Created a table with xmltype column refeencing above schema 3.