Java Desktop Database Application + Mysql

View: New views
8 Messages — Rating Filter:   Alert me  

Java Desktop Database Application + Mysql

by leok-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I want to develop a custom Java Desktop Database Application using Netbeans 6.1. If the database is running locally, the application works, but if i move the database on  another PC the application no longer works. The only change which I did it was in persistence.xml:


Code:
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/piese"/>

 changed with


Code:
<property name="toplink.jdbc.url" value="jdbc:mysql://192.168.0.1:3306/piese"/>



User name and password are the same on both Mysql servers.

I tried to debug the application to find any error, but there is no error. The application runs but stops at this line:


Code:
entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("piesePU").createEntityManager();







I have all rights in mysql. I can connect from Netbean's window Services to the database and make changes on it.



Java Desktop Database Application does not work unless the database is on a local server?





Re: Java Desktop Database Application + Mysql

by Lovas Bence :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I don't know, if you checked: You can connect to mysql server - by
default - only from local host. You have to change some setting:
    - in the my.cnf file (the server main config file) comment out the
line: bind-address: 127.0.0.1
    - create user, how has right's on the schema (not only from
localhost): GRANT SELECT, INSERT, UPDATE,             DELETE ON schema.*
TO 'user'@'%' IDENTIFIED BY 'password';
            % means the user can connect from all hosts.

> Hi, I want to develop a custom Java Desktop Database Application using Netbeans 6.1. If the database is running locally, the application works, but if i move the database on  another PC the application no longer works. The only change which I did it was in persistence.xml:
>
>
> Code:
> <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/piese"/>
>
>  changed with
>
>
> Code:
> <property name="toplink.jdbc.url" value="jdbc:mysql://192.168.0.1:3306/piese"/>
>
>
>
> User name and password are the same on both Mysql servers.
>
> I tried to debug the application to find any error, but there is no error. The application runs but stops at this line:
>
>
> Code:
> entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("piesePU").createEntityManager();
>
>
>
>
>
>
>
> I have all rights in mysql. I can connect from Netbean's window Services to the database and make changes on it.
>
>
>
> Java Desktop Database Application does not work unless the database is on a local server?
>
>
>
>
>  


Re: Java Desktop Database Application + Mysql

by Lovas Bence :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've forgot...
If you change the my.cnf file, restart the server.

by

> Hi, I want to develop a custom Java Desktop Database Application using Netbeans 6.1. If the database is running locally, the application works, but if i move the database on  another PC the application no longer works. The only change which I did it was in persistence.xml:
>
>
> Code:
> <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/piese"/>
>
>  changed with
>
>
> Code:
> <property name="toplink.jdbc.url" value="jdbc:mysql://192.168.0.1:3306/piese"/>
>
>
>
> User name and password are the same on both Mysql servers.
>
> I tried to debug the application to find any error, but there is no error. The application runs but stops at this line:
>
>
> Code:
> entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("piesePU").createEntityManager();
>
>
>
>
>
>
>
> I have all rights in mysql. I can connect from Netbean's window Services to the database and make changes on it.
>
>
>
> Java Desktop Database Application does not work unless the database is on a local server?
>
>
>
>
>  


Java Desktop Database Application + Mysql

by leok-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I created the user and I gave all the rights. As I said in the first post, I can connect from Netbeans Database client to the database (from 192.168.0.1) and make changes on it. I have written a simple program (a simple select query), which display the results in the console. It works.

So I think the problem is elsewhere ... That's why I asked if the Java Desktop Database Application only work with a local database.





Re: Java Desktop Database Application + Mysql

by Lovas Bence :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, I'm just try to find the problem. I develop an applet which uses
jpa to connect to remote database (not in local network), and I haven't
any problem...
> I created the user and I gave all the rights. As I said in the first post, I can connect from Netbeans Database client to the database (from 192.168.0.1) and make changes on it. I have written a simple program (a simple select query), which display the results in the console. It works.
>
> So I think the problem is elsewhere ... That's why I asked if the Java Desktop Database Application only work with a local database.
>
>
>
>
>  


Re: Java Desktop Database Application + Mysql

by Rick Fincher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi leok,

Please leave all the threads to you messages in the reply, we can't
scroll down and see what you wrote before.

The IP address 192.168.0.1 is an internal IP address, it won't go
through a router.  If the server machine is on a different network
branch you won't be able to reach it with that IP address.

Is the database server you used for development the same one that you
are trying to access in production mode?

Rick

leok wrote:
> I created the user and I gave all the rights. As I said in the first post, I can connect from Netbeans Database client to the database (from 192.168.0.1) and make changes on it. I have written a simple program (a simple select query), which display the results in the console. It works.
>
> So I think the problem is elsewhere ... That's why I asked if the Java Desktop Database Application only work with a local database.
>
>
>
>  


Java Desktop Database Application + Mysql

by leok-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I want to thank you for your help, I found the problem. The program does not work because I use a proxy, after I turned off the proxy and used direct connection I managed to get connected. :D

I set the XP to not use proxy for the address 192.168.0.1 and now the program works.




Rick Fincher wrote:
> Hi leok,

>

> Please leave all the threads to you messages in the reply, we can't

> scroll down and see what you wrote before.

>

> The IP address 192.168.0.1 is an internal IP address, it won't go

> through a router.  If the server machine is on a different network

> branch you won't be able to reach it with that IP address.

>

> Is the database server you used for development the same one that you

> are trying to access in production mode?

>

> Rick

>

> leok wrote:

>
> > I created the user and I gave all the rights. As I said in the first post, I can connect from Netbeans Database client to the database (from 192.168.0.1) and make changes on it. I have written a simple program (a simple select query), which display the results in the console. It works.

> >

> > So I think the problem is elsewhere ... That's why I asked if the Java Desktop Database Application only work with a local database.

> >

> >

> >

> >
>
 :D  :D  :D





Re: Java Desktop Database Application + Mysql

by mumujamm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have the same problem, only I know my persistence.xml isn't getting read properly.  

I've searched, and I've found where to put the file for a web app, but not for a desktop app.  I've tried in the same dir, in META-INF, META-INF/src, etc, and it isn't getting read.  Any advice on this?

leok-2 wrote:
Hi, I want to develop a custom Java Desktop Database Application using Netbeans 6.1. If the database is running locally, the application works, but if i move the database on  another PC the application no longer works. The only change which I did it was in persistence.xml:


Code:
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/piese"/>

 changed with


Code:
<property name="toplink.jdbc.url" value="jdbc:mysql://192.168.0.1:3306/piese"/>



User name and password are the same on both Mysql servers.

I tried to debug the application to find any error, but there is no error. The application runs but stops at this line:


Code:
entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("piesePU").createEntityManager();







I have all rights in mysql. I can connect from Netbean's window Services to the database and make changes on it.



Java Desktop Database Application does not work unless the database is on a local server?