Connecting to a database from another computer...

hi guys!
i just wonder if there is a simple way to connect to my database from another computer?
do you have to change something in this method?
    private static Connection getConnection() {     Connection con = null;     try {         Class.forName("com.mysql.jdbc.Driver");         String url = "jdbc:mysql://localhost/Movies";         String user = "root";         String pw = "x";         con = DriverManager.getConnection(url, user, pw);         System.out.println("****Connected****");     }     catch (ClassNotFoundException e)     {         System.out.println(e.getMessage());           System.out.println("1");         System.exit(0);     }     catch (SQLException e) {         System.out.println(e.getMessage());           System.out.println("2");           System.exit(0);     }         return con;     }
thanks! :)
Edited by: Shaor-1 on Dec 22, 2008 3:47 AM

hey!
is there no one who knows how to do this?
Here is my program that i want to change so it can connect to my mysql database but from another computer.
import java.sql.*;
import java.text.NumberFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ListMovies {
        static String exist = "existed";
    static int ye = 2221;
    static double pr = 21.12;
public static void main (String[] args) throws InterruptedException {
go();
public static void go(){
       NumberFormat cf = NumberFormat.getCurrencyInstance();
    for(int i = 0; i < 1; i--){
    ResultSet movies = getMovies();
    try
        while (movies.next()){
            Movie m = getMovie(movies);
            String msg = Integer.toString(m.year);
            msg += ": " + m.title;
            msg += " (" + cf.format(m.price) + ")";
            System.out.println(msg);
          Thread.sleep(1000*10);
            catch (InterruptedException ex) {
                Logger.getLogger(ListMovies.class.getName()).log(Level.SEVERE, null, ex);
            }    catch (SQLException e)
        System.out.println(e.getMessage());
public static void loanMovie(String d) {
    Connection con = getConnection();
    try {
        Statement stmt = con.createStatement();
        String insert = "insert into movie "
                + "(title, year, price) "
                + "values ("
                + "\"" + d + "\"" + ", "
                + ye + ", " + pr +");";
        int i =stmt.executeUpdate(insert);
        if (i == 1){
            System.out.println("Loan recorded");
        else
            System.out.println("Loan not recorded");    
    catch (SQLException e){
        System.out.println(e.getMessage());
        System.out.println("CRAP"); 
private static ResultSet getMovies()
    Connection con = getConnection();
    try {
        Statement s = con.createStatement();
        String select = "Select title, year, price " +
                "from movie order by year";
        ResultSet rows;
        rows = s.executeQuery(select);
        return rows;
    catch (SQLException e)
        System.out.println(e.getMessage());
    return null;
    private static Connection getConnection() {
     Connection con = null;
     try {
         Class.forName("com.mysql.jdbc.Driver");
         String url = "jdbc:mysql://localhost/Movies";
         String user = "root";
         String pw = "x";
         con = DriverManager.getConnection(url, user, pw);
         System.out.println("****INFO****");
     catch (ClassNotFoundException e)
         System.out.println(e.getMessage());
           System.out.println("1");
         System.exit(0);
     catch (SQLException e) {
         System.out.println(e.getMessage());
           System.out.println("2");
          System.exit(0);
        return con;
    private static Movie getMovie(ResultSet movies) {
        try {
            String title = movies.getString("Title");
            int year = movies.getInt("Year");
            double price = movies.getDouble("price");
            return new Movie(title, year, price);
        catch (SQLException e)
        System.out.println(e.getMessage());   
        return null;
    private static class Movie
        public String title;
        public int year;
        public double price;
        public Movie(String title, int year, double price)
            this.title = title;
            this.year = year;
            this.price = price;
BTW_
my computers ip is: 81.229.40.17
the database is on that computer.
thanks!

Similar Messages

  • Connect on an oracle database from another computer

    hi all,
    i installed oracle database 10g express as well as sql developer on one of my laptop. Everything is ok as of the moment.
    Now, i want to access that oracle database from my another laptop. Is this possible? let me know what should i do in order to achieve this.
    thanks.

    user13169035 wrote:
    thanks for the help. basically here is the setup.
    i have 2 laptops. the first one has oracle 10g database express install and sql developer. i can query my database from here using sql developer.
    now, on my second one, i want to access the data from the database that i created from the first laptop. i want to access the data from the database from the first laptop using sql developer which i also installed on the 2nd laptop.
    i already tried the link from http://www.oracle.com/technology/software/products/database/xe/files/install.102/b25144/toc.htm but didnt work (or maybe i missed something important).
    What from the link did you try to follow? Did you try to follow the information in the link i posted, specifically ...
    "4.4 Making Oracle Database XE Server Available to Remote Clients"
    Once you have done that. You will need to know the IP or possible computer name of the computer on the network which is hosting the database (it would be easiest if the laptop with the database had a static IP assigned by your router, assuming this is a home setup, and you use that for your connection). You will need that information to create a new connection in SQLDeveloper on the laptop without the database installed.
    Aside from that you may have to deal with windoze firewall issues and the like, but that removes this from being an Oracle question, you should be able to use google to deal with any issues you encounter in that.

  • Unable to open 10g Database Control Webpage from another computer

    Unable to open 10g Database Control Webpage from another computer
    Hi Gurus
    I have just installed Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 on my PC Windows XP , created database and configured DB control
    I can open Database Control Webpage on the database machine by typing
    http://USI2374993VND0.vlgdw2k.visteon.com:1158/em
    or
    http://136.18.70.189:1158/em
    But can not open it from another PC
    When I do following from another PC
    1. http://USI2374993VND0.vlgdw2k.visteon.com:1158/em
    Get error: [code=DNS_NO_DATA] The IP address was not found during the DNS lookup. Contact your system administrator.
    2. http://136.18.70.189:1158/em
    Get error:Can not display web page
    I can ping 136.18.70.189 but not USI2374993VND0.vlgdw2k.visteon.com
    On the other PC I also tried adding 136.18.70.189 to
    tools - internet options - security - local internet - sites - advanced - add this web
    site to the zone as http://136.18.70.189
    But it did not work
    Please help with any ideas
    Thanks a bunch
    New DBA

    Firewalls?
    DNS translation issues?

  • Not able to connect database from another os user using externally?

    Hi,
    I want to connect database from another os user. i am able to connect database from oracle externally. but not able to connect different OS user.
    As ORACLE User:
    [oracle@test1 admin]$ sqlplus /
    SQL*Plus: Release 11.2.0.2.0 Production on Mon Jan 16 19:41:57 2012
    Copyright (c) 1982, 2010, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    Non ORACLE user:
    [sample@test1 ~]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/
    [sample@test1 ~]$ export ORACLE_SID=rman
    [sample@test1 ~]$ export PATH=$ORACLE_HOME/bin:$PATH
    [sample@test1 ~]$ sqlplus /
    SQL*Plus: Release 11.2.0.2.0 Production on Mon Jan 16 19:37:42 2012
    Copyright (c) 1982, 2010, Oracle. All rights reserved.
    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux Error: 2: No such file or directory
    Process ID: 0
    Session ID: 0 Serial number: 0
    Enter user-name:
    Thanks

    You didn't install Oracle correctly, especially you didn't run the root.sh and rootpre.sh scripts.
    If you would have read the error message at all, and researched it, you would have known this.
    Regrettably however you decided to ignore Forums Etiquette and to abuse this forum with Yet Another Doc Question.
    Sybrand Bakker
    Senior Oracle DBA

  • How do I stop my Macbook Air from transferring your information from another computer?

    Just purchased my Macbook Air. When I started it up, it asked if I wanted to tranfer information from my other computer. the first thing it started to download was the music and it suddenly froze when it had a 1hr and 46 mins left and now I can escape out of it. It is the only thing that is on my screen. I ended the transfer on my PC but it wont clear out on my Macbook Air. Is there a way to restart the computer so it will retry the tranfer without the music?

    Welcome to Apple Support Communities
    Hold the Power button until the Mac turns off, and turn it on again.
    Instead of transferring your files from another computer through the network, copy your data from your old PC or Mac to an external drive, connect the external drive to your MacBook Air and transfer your files

  • Can't sync photos from ipad that I synced from another computer

    Can't sync photos from ipad that I synced from another computer... I want to have them on my computer.
    Why isn't there a way to do this? I don't get it. Sharing photos is such an important thing I don't understand why Apple makes it so hard to do this.
    OK here is my senario:
    Recently went on a trip Hong Kong with someone... we both had iphones and took hundreds of awesome photos. Now we want to share them with eachother. Too many photos for email and I don't wish to upload to flicker/facebook/etc...
    This is what I did thinking it should work...
    1) synced photos on her iphone with her computer
    2) synced photos on MY iphone with her computer
    3) put ALL the hong kong photos in one album
    4) connected my ipad to her computer... attempted to copy photos from iphoto to ipad -- NOPE, can't be done (***?!?!)
    5) so I synced the photos (and only the photos) in the hong kong album using itunes to my ipad -- this worked -- all photos now on my ipad
    6) drove home (5 hours away) and connected ipad to my computer and attempted to import with iphoto -- NOPE, can't be done (***!?!?) Won't even show the photos.
    7) itunes wants to replace all the photos on my ipad with the photos from my computer (***?!?!)
    How are you suppose to do this?! How are you suppose to be able to share lots of photos with people?

    Photos are not copied off the iPad via iTunes.
    For photos taken with the iPad, copied to it via the camera connection kit, or saved from emails/websites then see this page : http://support.apple.com/kb/HT4083
    For photos that were originally synced from a computer you will need a third-party app such as Simple Transfer (which has a free lite version called Simple Photo & Video Transfer) which can copy them off via your wifi network. But as photos are 'optimised' when they are synced to the iPad, any that you then copy back to a computer may not be exactly the same as they originally were on your computer.

  • How to connect to SAP Database from a Adobe flex application?

    Hi
    I am an intern currently working on designing an Adobe flex interface that interacts with an SAP Database, although im torn between methods of implementing the most efficient connection without over-complicating the problem. I believe the best approach would be to use SAPJCo but am unfamiliar with how to approach this method and am finding it hard to get detailed documentation or code examples which show connecting to a Database. Another approach would be using a web service but my problems again arise with my lack of knowledge to connect to the Database.
    Any advice or help would be much appreciated.
    Thanks,
    Jonny

    Hi Jonathan.
    I believe webservice is the best approach, steps to create webservice is very simple.
    1. create a webservice from a standard rfc or bapi.
    2. release and activate webservice.
    3. it will generate wsdl file which can be used in flex environment.
    creating webservice.
    http://help.sap.com/saphelp_nw04s/helpdata/en/0d/2eac5a56d7e345853fe9c935954ff1/frameset.htm
    Consuming ABAP Web Services using Flex :
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/emtech/consuming%2babap%2bweb%2bservices%2busing%2bflex
    i hope this surely helps.
    Venkat.

  • My daughter has locked herself out of her ipod touch.  Ironically the computer it is synced to just crashed, is it possible to get her up and running from another computer?

    My daughter set a password and forgot it, she has locked herself out of her ipod touch.  The computer the ipod was synced w/ has crashed, is it possible to restore her settings from another computer?

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • If I can't download ios 5 software at home, can I download it from another computer?

    If I can't dowload ios 5 software at home, Can i download it from another computer and save the backup and put it onto my computer?

    No, you cannot download IOS5.
    You have to connect your iPhone to computer iTunes and do a update.
    Anyway you are in the wrong forum if that's what you want.

  • How to access Enterprise manager from another computer

    Hi There,
    I have Oracle 10g installed on a PC. I can access EM from that PC.
    I would like to know how would I access EM Dbconsole from another computer under same LAN.
    Thanks
    Raf

    Opening the web browser, you can specify the hostname and the port configured to listen the incoming call.
    For example:
    https://hostname:port_number/em
    or
    https://ip_address:port_number/em
    you can get information about the information that you need from the "emctl"
    emctl status dbconsole
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
    https://hostname:1158/em/console/aboutApplication
    Oracle Enterprise Manager 11g is not running.
    Best regards !
    Shin-Iti.

  • Is it possible to download songs from another computer?

    I have a new ipod shuffle that i just got it recently. I dont have internet connection currently because I'm travelling. Is it possible to download songs from another computer. My main computer would be my laptop.

    Yes but it would probably overwrite the songs currently on your iPod when it syncs to the new computer.

  • Uploading (sync) selected music from another computer?

    How do you upload (sync) selected music from another computer?

    If you want to use more than one computer with your iPod, then I would suggest using "Manually manage music and video" mode. I say that because when you go to the other computer and plug it in then your iPod is going to be erased of what is currently on it, and replaced with what your other computer has on it in iTunes. In order to get to that mode I mentioned up there you load up iTunes making sure that your iPod is connected and listed in iTunes, after it is all done syncing, click on your iPod in the source list, and then click on "Manually manage music and videos". If I were you, I would do this procedure on the computer that you have already plugged your iPod into, then after the procedure, you can use the other one. You are also going to have to go through an "Authorization" procedure. In order to do that, click on "Advanced" in iTunes and then scroll down to "Authorize this computer" and then follow any directions you may see. Oh and don't forget to click "Apply" at the bottom right of iTunes. Then you should be all set to use both computers. This will make it though so you have to manually copy music to your iPod as well as manually eject your iPod from iTunes.

  • How do I install Mac OS from another computer using firewire?

    My iMac has a bad CD drive but I was told that there is a way to install Leopard from another computer using a firewire connection between the two. I put the install CD in the other computer and rebooted it using "T" (and I see the floating firewire symbol as expected). But I don't see the install disk on the iMac. What's up?

    you can try another way:
    connect a firewire drive to the good Mac. Partition the drive and make the second partition as small as you can but at least 8 gigs. Mount he Leopard DVD to desktop. Launch Disk Utility and select that external drive and the restore tab. Drag the source , ie the MacOSX DVD to source window and that second small partition to the destination window. Select restore and enter your password. Wait 30 mins, restore is done. Quit all programs. Unmount that external drive. Connect to the "bad" Mac and restart it from that external drive to install Leopard OSX. You can if you want load most of your software on the first partition of the external and install your software unless of course you did a Time Machine to make it far simpler.

  • If I imported a CD into my iTunes library from one computer how can I listen to it from another computer?

    If I imported a CD into my iTunes library from one computer how can I listen to it from another computer?  I imported music from a CD into my compter at work and when I got home and went to my iTunes account none of the songs were in my library.  I also noticed that on my Work computer there were a couple songs that I had to click on the little 'cloud' icon before I could listen to them (these were not songs I imported they were songs that were already in my library).  Not sure if this makes semse...help.

    jamie171 wrote:
    My question is since I have imported them into my iTunes library from one computer why can't I access them from my iTunes library from another computer that I have authorized to access whats in my library?  Is there no way to import songs only once into the library and then access them from all my authorized computers?
    Only if you have iTunes Match or of the computers are on the same local network.

  • How do i use a Time Machine from another computer from Time Capsule with multibackups

    Can Iuse a Time Machine from another computer from Time Capsule with multibackups

    Not sure what you are asking here. 
    Time Machine is software on a Mac that is used to backup that Mac to a Time Capsule hard drive.
    Are you asking if another  Mac can backup to the same Time Capsule that other Macs are already using?
    Or, if not....please clarify on exactly what you want to do.

Maybe you are looking for