Results 1 to 16 of 16
  1. #1
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default client javadb connection over internet

    Hi All,

    I have a program which connect to a local database. But now i need to do some modification to let it connect to a remote database over internet.

    well, actually, this is the first time i will be getting connected to a remote database over internet. So i am also not sure what to do.. Could any of you tell me the needed steps to connect a remote database over internet? permissions, url address blah blah..

    database i use : javadb

    Thanks, if you need any other information, i will provide.. I am not asking for code, I have searched a lot thru google but nothing i could find.. i read some articles but i could not make myself clear..

    Thanks again. :o

  2. #2
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    well, the first thing i did, i used one of the computers in my network to make sure that i can connect a remote database at least..

    I got some error on that..

    when i write the code like this:
    Java Code:
    Class.forName("org.apache.derby.jdbc.ClientDriver");
    con = DriverManager.getConnection("jdbc:derby:/syazana/c/Data/Router","mahmud","123456");
    I get this error : java.sql.SQLException: Database '/syazana/c/Data/Router' not found.

    ok, when i write the code like this:
    Java Code:
    Class.forName("org.apache.derby.jdbc.ClientDriver");
    con = DriverManager.getConnection("jdbc:derby:[B]//[/B]syazana[B]//[/B]c/Data/Router","mahmud","123456");
    i get this error : Error connecting to server syazana on port 1527 with message Network is unreachable: connect.

    but, when i type "\\Syazana\C\Data\Router" to the windows explorer address bar, i can go to the location..

    Or do i have to upload it to internet first? i think i have some problems with the address of the database..

    can anyone help me out?

  3. #3
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    is there anyone who can help?

    thanks..

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    841
    Rep Power
    6

    Default

    Just go thru this below link which might be useful for you.
    Apache Derby Database - Tutorial
    Ramya:cool:

  5. #5
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    finally someone.. :o

    thanks, i will let you know when i am done reading it..

    :)

  6. #6
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    Quote Originally Posted by RamyaSivakanth View Post
    Just go thru this below link which might be useful for you.
    Apache Derby Database - Tutorial
    hi :o

    I got some problems..

    1. in the article, there is a part called "Installation of Derby", (I copied here)

    Installation of Derby
    Download the latest Derby version from the Apache website Apache Derby . Choose the bin distribution as it contains several helpful programs.

    Extract this zip to a directory of your choice.

    Derby allows to run in embedded mode or in server mode.

    If you want to use the Derby tool or Derby in Server mode do also the following:

    Set the environment variable DERBY_HOME to the Derby installation directory

    Add DERBY_HOME/bin to the path environment variable
    here I didnt get how to set the environment derby_home, I already installed it (when i started to my project) and i don't know how to change it now or is it really needed? it says "if you want to use derby in server mode" and i do want.

    2. for the part 3, "server mode" it says if we want to change the listened port, just type "startNetworkServer -p port_number" ex: startNetworkServer -p 3301

    but it doesnt work, even i type that, the response i get is

    Security manager installed using the Basic server security policy.
    Apache Derby Network Server - 10.4.2.1 - (706043) started and ready to accept co
    nnections on port 1527 at 2010-04-30 07:47:26.875 GMT
    i just skipped evendo it doesnt work..

    i configured my code by changing the

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby:Data/Router","mahmud","123456");
    to:

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby://192.168.1.102:1527/Data/Router","mahmud","123456");
    i run the apache server like this "startNetworkServer" and it started with this message:

    Security manager installed using the Basic server security policy.
    Apache Derby Network Server - 10.4.2.1 - (706043) started and ready to accept co
    nnections on port 1527 at 2010-04-30 07:47:26.875 GMT
    instead of connecting over internet, i just want to connect to another pc in my network first. so i shared the database in folder "Data"
    from another pc, i can access it with no problem when i type "\\OmerHalit\Route Finder\Data"

    server ip : 192.168.1.102
    default port : 1527

    but there are some errors i got :

    if my code is

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby://192.168.1.102:1527/Data/Router","mahmud","123456");
    i get this

    java.net.ConnectException : Error connection to server 192.168.1.102 on port 1527 with message Connection refused: connect
    I turned off kis2010 and windows firewall on server and other pc, it's still the same.

    --------------
    if my code is

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby://192.168.1.102:1178/Data/Router","mahmud","123456");
    i get this

    java.net.ConnectException : Error connection to server 192.168.1.102 on port 1178 with message Connection refused: connect
    i checked the port between server and the other pc thru kaspersky -> network monitor, and i saw the it uses port 1178(external port) and (139 as local port)
    when i click login in other pc, in network monitor screen, the value of "bytes received" increases but it still says "connection refused" so i think they can connect to each other but something blocks and i dont know what, no firewall and no antivirus software is enabled..

    when i tried port 139 this is the error i got :

    Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 4 bytes. The connection has been terminated.
    and in the network monitor screen of kaspersky, bytes received and sent colums becomes 0(zero) byte and when i try port 1178, it establishes the connection again and received bytes increases..

    just to remind you that apache servers accepts from port 1527 only, even i typed the proper command to make it listen other ports..

    These are everything i got so far, can you help me to find the problem? thanks..

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by OmerHalit View Post
    hi :o

    I got some problems..

    1. in the article, there is a part called "Installation of Derby", (I copied here)



    here I didnt get how to set the environment derby_home, I already installed it (when i started to my project) and i don't know how to change it now or is it really needed? it says "if you want to use derby in server mode" and i do want.
    How to set it depends on your OS. e.g on Windows you could set it at the same place where you set your PATH variable.
    Quote Originally Posted by OmerHalit View Post
    2. for the part 3, "server mode" it says if we want to change the listened port, just type "startNetworkServer -p port_number" ex: startNetworkServer -p 3301

    but it doesnt work, even i type that, the response i get is



    i just skipped evendo it doesnt work..
    That is not an error. Read that message. It's telling you that you have successfully started the DB and the port at which it's listening for connections.
    Quote Originally Posted by OmerHalit View Post

    i configured my code by changing the

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby:Data/Router","mahmud","123456");
    to:

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby://192.168.1.102:1527/Data/Router","mahmud","123456");
    i run the apache server like this "startNetworkServer" and it started with this message:



    instead of connecting over internet, i just want to connect to another pc in my network first. so i shared the database in folder "Data"
    from another pc, i can access it with no problem when i type "\\OmerHalit\Route Finder\Data"

    server ip : 192.168.1.102
    default port : 1527

    but there are some errors i got :

    if my code is

    Java Code:
    //con = DriverManager.getConnection("jdbc:derby://192.168.1.102:1527/Data/Router","mahmud","123456");
    i get this


    java.net.ConnectException : Error connection to server 192.168.1.102 on port 1527 with message Connection refused: connect
    That is a connection issue. First make sure you can ping that IP from your computer. If you can't then you have network issues that have nothing to do with databases. If you can, try to see if you can telnet into that port.
    If you can't then you still have network issues.
    Only after you can telnet that port should you try connecting with your Java code.

  8. #8
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    ok, i will try it now.. thanks

  9. #9
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    yes i can ping to the server (192.168.1.102)

    byte = 32 / time = 1ms / TTL = 128

    but i cannot connect thru telnet, i tried like this:

    telnet 192.168.1.102 1527

    but i can connect and see and copy bla bla using windows explorer.. so what do i need to do now? what possiblities are there that can block it connect?

  10. #10
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    wait a minute,

    is there anything wrong with port 135? because i can connect via port 135 it hangs, i also can connect via port 139 but it disconnects after a while and i cant do anything while it is connected. i just see the ip address on top of the cmd window and i cant type anything, nothing appears but the cursor moves..

    and each time i press any key, the connection indicator (Windows XP, near system time, two pc screen icon) blinks..

  11. #11
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Don't woory about other ports. Worry about the port that your database is listening on.
    If that port is 1527 then you need to make sure people can telnet to that port. You might need to get a network expert to help if you don't understand the output of those commands.

  12. #12
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    well, i will try to solve that problem,

    but my target is not that actually, i have a java desktop application, i want it to connect to database over internet (not lan).. but there are some questions in my mind.. (this program will be used by many users, speed is not problem)

    1. how do i need to put the database to internet? i just uploaded my folder to a free web hosting storage. I created a simple web page, an i uploaded it to the storage. It looks so nonsence to me actually, because i don't think the application can access it.

    2. i feel, i have to spare one pc as my own server, run an ftp server application on the server, and ..? how to put restrictions and permissions..

    and, does the apache server have to be running on the server? if yes, my first option is useless..

    can you give me a way to follow??

    thanks again..

  13. #13
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by OmerHalit View Post
    well, i will try to solve that problem,
    I've seen you juggling with that URL over and over again, but it should simply be like this:

    jdbc:derby://<your host>:1527/<your db>

    The terms <your host> and <your db> translate to the host name of your server host (or its IP address) and <your db> should be the name of your database, not a complete path to a file that contains your JavaDB/Derby database.

    Of course you should have JavaDB/Derby up and running on that host.

    kind regards,

    Jos

  14. #14
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    i tried many things, but it didn't work..

    i run the derby server in my pc,

    i tried to connect to my pc from another pc in my LAN. but it keep refusing the connection. I dont know why, i turned off everything, firewall, antiviruses.. but i couldnt get it done.

    maybe i couldnt run the server properly..

    i run the server from cmd but it didnt work, then i run it from netbeans platform.. nothing.. same problem occured.. connection refused..

    Thanks.:o

  15. #15
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,657
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by OmerHalit View Post
    maybe i couldnt run the server properly..
    Check that first; on your server host in the directory pointed to by derby.system.home there should be a derby.log file. What does it say?

    kind regards,

    Jos

  16. #16
    OmerHalit is offline Member
    Join Date
    Mar 2010
    Posts
    41
    Rep Power
    0

    Default

    it says this :

    ----------------------------------------------------------------
    2010-05-24 19:13:48.828 GMT:
    Booting Derby version The Apache Software Foundation - Apache Derby - 10.4.2.1 - (706043): instance a816c00e-0128-cbbc-3347-0000001907f8
    on database directory D:\Projects\Java\ObjectOrientedProgramming\TravelR oute\Data\Router

    Database Class Loader started - derby.database.classpath=''

    is this what you asked for?

    Thanks.

Similar Threads

  1. Java client - proxy connection
    By ragnonerodocet in forum Networking
    Replies: 0
    Last Post: 03-10-2010, 06:21 PM
  2. Java Client Needs Database Acces Over Internet
    By etherkye in forum Networking
    Replies: 2
    Last Post: 07-01-2009, 10:44 AM
  3. Connection reset error in FTP client
    By Waterbottle in forum Networking
    Replies: 0
    Last Post: 03-23-2009, 09:03 AM
  4. pc give internet connection to mobile
    By dimitrist in forum New To Java
    Replies: 0
    Last Post: 12-21-2008, 02:22 PM
  5. Client Internet Explorer Setting
    By Mir in forum Networking
    Replies: 29
    Last Post: 06-26-2008, 12:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •