Insert in Table

Leave a reply                     

Insert in Table in Java

MySql Insert into Table

Java Insert in MySql table

How to Insert Data in MySql Table in Java

Following INSERT statement is used to insert data “www.” in database table tablename in column columnname2, the value for column columnname1 automatically inserted since it is auto increment column.
INSERT INTO tablename(columnname2) values (‘www.’)


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class InsertInTable {

	 * @param args
	public static void main(String[] args) {
		try {
			Connection connection = DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/databasename", "root", "");
			Statement statement = connection.createStatement();
					.executeUpdate("INSERT INTO tablename(columnname2) values ('www.')");
		} catch (SQLException e) {
		} catch (ClassNotFoundException e) {

Leave a Reply

Your email address will not be published. Required fields are marked *

× 2 = twelve