Hi Venu,
Thanks for ur response.
Ur first guess is correct ... mysqld server is not running.
But whenever i tried to run it, it is showing this error:
011118 13:59:01 Can't start server : Bind on unix socket: Address
already in use
011118 13:59:01 Do you already have another mysqld server running
on socket:/tmp/mysql.sock ?
011118 13:59:01 Aborting
I have tried to run it on different ports using -P option. But still
i am getting same error.
regds,
Prasad.
-----Original Message-----
From: Venu [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 17, 2001 9:39 PM
To: Prasad Valmeti; Nguyen Trong Phuc; [EMAIL PROTECTED]
Subject: RE: java.sql.SQLException: Cannot connect to MySQL server
onlocalhost:3306.
Hi,
> -----Original Message-----
> From: Prasad Valmeti [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, November 17, 2001 4:31 AM
> To: Nguyen Trong Phuc; [EMAIL PROTECTED]
> 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.
The possible reasons are:
1. The server is not up and running
2. The server is up and running, but not to the default port.
Regards, venu
>
> 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.
>
--
For technical support contracts, go to https://order.mysql.com
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Venu <[EMAIL PROTECTED]>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Developer
/_/ /_/\_, /___/\___\_\___/ California, USA
<___/ www.mysql.com
>
---------------------------------------------------------------------
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