I want to add data entered from Java GUI into mysql database and inside actionlestener I am using the following code:

String s1;
JTextField enterdata = new JTextField(10);
PreparedStatement ps = con.prepareStatement("INSERT INTO d (name) VALUES (?)");
ps.setString(1, s1);

'name' is the column in database;
i am having a successful connection to database but the data field entry into database is blank but on every insertion, it prompts 1 row inserted but the data is not seen inside the database.
please help.

This is al ablout timing - when things happen.

JTextField enterdata = new JTextField(10);

This creates a text field and immediately queries it for the text it contains. At this time the text is still "", so that's what yu add to the database.
You need to create the text field when initialising, but you can't query its contents until after the use has had a chance to type something into it.
It would also be a good idea to display the text field in some kind of window - ar maybe you just omitted that code for simplicity :)