I want to read mysql connection info with java. For example I made a server socket with java on port 4444. Then I made a jdbc driver with url "jdbc:mysql://127.0.0.1:4444/mysql". My mysql is running on port 3306.
I wrote something like below in client class:
which CONNECTION is "jdbc:mysql://127.0.0.1:4444/mysql"Code :
Connection c = DriverManager.getConnection(CONNECTION,p);
and in server I have this:
the server get the clientSocket but "clientSocket.getInputStream().available()" is 0.Code :
clientSocket = ss.accept();
I really don't know how to fix this problem. I have to know which database, client wants to connect and also I don't want to change the client's source code.
I then wrote this in server class, hope this would solve the problem, but it didn't work
Maybe the way I fix the problem is wrong. if it is, please help me how to write a proxy server for my databaseCode :
Connection c = DriverManager.getConnection(CONNECTION,p); ObjectOutputStream oo=new ObjectOutputStream(clientSocket.getOutputStream()); oo.writeObject(c);