Hi Venu !
First, u should try use :

    Connection con = DriverManager.getConnection(HOST + DB, ACCOUNT,
PASSWORD);

intead of Properties. I writer java servlet, so i placed mm.driver in lib
dir of each context, what's version of yr mm.driver, i'm using 2.0.4. u can
know what's port running by "nmap" (included in power tools disk of RedHat)
    $nmap localhost
u will know what service with what port is running
or : $ps -aux / $ps -e to know mysqld is running.

good luck
Trong Phuc

----- Original Message -----
From: "Prasad Valmeti" <[EMAIL PROTECTED]>
To: "Nguyen Trong Phuc" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, 17 November, 2001 4:31 AM
Subject: java.sql.SQLException: Cannot connect to MySQL server on
localhost:3306.


Thanks for ur response.
I am sending code also. Earlier it was connected to data base.
I haven't used it sometime. Now i am trying but unable to connect to Data
base.

Please have look and suggest me some solution to solve this problem.

import java.io.*;
import java.sql.*;
import java.util.*;

public class TextToDatabaseTable {
   private static final String DB = "secmngr",
                               TABLE_NAME = "records",
                               HOST = "jdbc:mysql://localhost:3306/",
                               ACCOUNT = "scott",
                               PASSWORD = "tiger",
                               DRIVER = "org.gjt.mm.mysql.Driver",
                               FILENAME = "records.txt";

   public static void main (String[] args) {
      try {

         // connect to db
         Properties props = new Properties();
         props.setProperty("user", ACCOUNT);
         props.setProperty("password", PASSWORD);

         Class.forName(DRIVER).newInstance();
         Connection con = DriverManager.getConnection(HOST + DB, props);
         Statement stmt = con.createStatement();

         // open text file
         BufferedReader in = new BufferedReader(
                                new FileReader(FILENAME));

         // read and parse a line
         String line = in.readLine();
         while(line != null) {

            StringTokenizer tk = new StringTokenizer(line);
            String first = tk.nextToken(),
                   last = tk.nextToken(),
                   email = tk.nextToken(),
                   phone = tk.nextToken();

            // execute SQL insert statement
            String query = "INSERT INTO " + TABLE_NAME;
            query += " VALUES(" + quote(first) + ", ";
            query += quote(last) + ", ";
            query += quote(email) + ", ";
            query += quote(phone) + ");";
            stmt.executeQuery(query);

            // prepare to process next line
            line = in.readLine();
         }
         in.close();
      }

      catch( Exception e) {
         e.printStackTrace();
      }
   }

   // protect data with quotes
   private static String quote(String include) {
      return("\"" + include + "\"");
   }
}

I am not sending errors because those are in the below mails.

Thanks,
Prasad.
-----Original Message-----
From: Nguyen Trong Phuc [mailto:[EMAIL PROTECTED]]
Sent: Sunday, November 18, 2001 8:50 AM
To: Prasad Valmeti; [EMAIL PROTECTED]
Subject: Re: hai


Hi Valmeti !

it's general error, have too many reason. how about yr source code.
maybe grant access, mm.mysql driver ...


----- Original Message -----
From: "Prasad Valmeti" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, 17 November, 2001 2:49 AM
Subject: hai




Hai All,
I am using Mysql, JDBC on LINUX.
I am unable to connect Mysql from JDBC.

I am getting these errors ::


java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:320)
        at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:133)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:120)
        at java.net.Socket.<init>(Socket.java:273)
        at java.net.Socket.<init>(Socket.java:100)
        at org.gjt.mm.mysql.MysqlIO.<init>(MysqlIO.java:114)
        at org.gjt.mm.mysql.Connection.<init>(Connection.java:229)
        at org.gjt.mm.mysql.Driver.connect(Driver.java:126)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:146)
        at TextToDatabaseTable.main(TextToDatabaseTable.java:23)
java.sql.SQLException: Cannot connect to MySQL server on localhost:3306. Is
ther
e a MySQL server running on the machine/port you are trying to connect to?
(java
.net.ConnectException)
        at org.gjt.mm.mysql.Connection.<init>(Connection.java:239)
        at org.gjt.mm.mysql.Driver.connect(Driver.java:126)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:146)
        at TextToDatabaseTable.main(TextToDatabaseTable.java:23)


Please help me to solve out this problem.
Thanks,
 Prasad.

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to