Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8577167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:05:58+00:00 2026-06-11T20:05:58+00:00

UPDATE: I solved this problem exactly the same way friends suggested. But I kind

  • 0

UPDATE: I solved this problem exactly the same way friends suggested. But I kind of missed the fact that I have to follow mysql’s protocol in order to get the result. In mysql there is always an initial handshaking packets doesn’t have any data field so you don’t get any data with getInputStream. The only way is to create a mysql connection in your own server and send the result to your client. It works very well. Thank you everybody

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 connection on port 4444. But it doesn’t work. I don’t know why and even I don’t know if it is possible or not.
This is the sever code:

int portNr = 4444;
// Create a ServerSocket object to watch that port for clients
ServerSocket ss;
try {
    ss = new ServerSocket(portNr);

    System.out.println("starting...");

    // Here we loop indefinitely, just waiting for clients to connect
    while (true) {

        // accept() does not return until a client requests a connection
        // Now that a client has arrived, create an instance of our
        // special
        // thread subclass to respond to it.
        Socket clientSocket = null;
        try {
            clientSocket = ss.accept();

            System.err.println("heheh"+clientSocket);
            // PrintWriter out = new
            // PrintWriter(clientSocket.getOutputStream(), true);
            BufferedReader in = new BufferedReader(
                  new InputStreamReader(clientSocket.getInputStream()));
            String inputLine = in.readLine();
            System.err.println(inputLine)....;</i>

It prints “hehehe”; but it doesn’t print input line.

And this is my connection code:

public class messagetest
{
    // The JDBC Connector Class.
    private static final String dbClassName = "com.mysql.jdbc.Driver";

    private static final String CONNECTION =
                      "jdbc:mysql://127.0.0.1:4444/shadi";

    public static void main(String[] args) throws
                         Exception,SQLException
     {
        System.out.println(dbClassName);

        Class.forName(dbClassName);

        // Properties for user and password. Here the user and password are both 'paulr'
        Properties p = new Properties();
        p.put("user","--------");
        p.put("password","-------");

        System.err.println("after p");
        Connection c = DriverManager.getConnection(CONNECTION,p);

        System.err.println("client:");

It doesn’t print “client:”
Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:05:59+00:00Added an answer on June 11, 2026 at 8:05 pm

    You cannot bind your own Server on the same port as the DB-Server instance.

    If you really want to “monitor” it like that, use a little “man in the middle”: Set the DB to another port, say 4445. Then inside your monitor listen on 4444, that clients will connect to and make your own connection to 4445. Then forward input and output between the two.

    EDIT:
    OK, we cleared that up. Forget about the first part of my answer.

    Your server runs on 4444 and your db on 3306.

    So in your monitor, you’ll need two connections: One Monitor-Client and one Monitor-DB.
    You’ll have to have two threads reading on each of them and writing what it has read to the other.

    And I don’t know if you will be happy using readLine. For checking out what is being sent, I recommend reading bytes …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update II Problem Solved but Why? This has been the biggest headache ever. My
This is not exactly a straight-out question because I have just solved it, but
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:
Updated Problem solved, I have some design problem here. The directory looks like that:
update I solved this problem by myself. I put it here for further reference.
[Update] Unfortunately I never had an opportunity to solve this problem. However, there are
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
EDIT: Update - scroll down EDIT 2: Update - problem solved Some background information:
I have a site that has an IE8-only problem: The code is: var w
I experienced this problem in VS2010 before, and solved it looking at this SO

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.