June 13, 2009 at 11:12 AM
Hi Friend,
Try the following code:
import java.sql.*;
class Insert{
public static String url = "jdbc:
mysql://192.168.10.211:3306/";;
public static String db = "mysql";
public static String driver = "com.mysql.jdbc.Driver";
public Insert(String url,String db,String driver){
this.url=url;
this.db=db;
this.driver=driver;
}
public void insertData(){
Connection con =null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url+db,"root","root");
}catch(Exception e){}
try{
Statement st = con.createStatement();
int val = st.executeUpdate("INSERT country VALUES("+1+","+"'India'"+")");
System.out.println("1 row affected");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
}
}
public static void main(String[] args){
Insert insert = new Insert(url,db,driver);
insert.insertData();
}
}
Thanks
Related Tutorials/Questions & Answers:
Advertisements
how to insert data into database using jsp & retrivehow to
insert data into
database using jsp & retrive Hello,
I have created 1 html page which contain username, password & submit button. in my oracle10G
database already contain table name admin which has name, password
how to insert data in database using html+jsphow to
insert data in
database using html+jsp anyone know what... = null;
// declare a resultset that uses as a table for output
data from... and
database name. Here machine name id localhost and
database name
insert data in the database using checkboxinsert data in the
database using checkbox i am fetching
data from the
database using servlet on the jsp page and there is checkbox corresponding... should i
insert only checked
data into
database on submission.
We
using oops concepts - Development processusing oops concepts You are required to develop a Hotel Reservation System.
The system manages information about rooms, reservations, customers... total source code in corejava
using oops concepts. Hi
Insert image from user using and save in databaseInsert image
from user
using and save in database when i am trying to upload a image
from user and trying to save into oracle9i
database... = connection.prepareStatement("
insert into file(file_
data) values(?)");
fis = new
using oops concepts - Development processusing oops concepts i want answer with
oops concepts.individual classes with source code and exact out put.
You are required to develop a Hotel Reservation System.
The system manages information about rooms
Insert data in Excel File from Database using JSP
Insert data in Excel File
from Database
using
JSP ... will retrieve the
data from database, create an excel file and
data
insert... developed a application to
insert data in excel file
from database in JSP. We
How to get data from Oracle database using JSPHow to get
data from Oracle
database using JSP hello i have a simple problem in jsp in the sense to get
data from the
database like oracle . I have... the answer to retrieve
data from the
database by
using servlet or jsp program
how to insert data from netbeans into databsehow to
insert data from netbeans into databse
how to
insert data from netbeans into databse
Please visit the following link:
http://www.roseindia.net/webservices/web-services-database.shtml
insert and delete data in databaseinsert and delete
data in database
insert and delete
data in
database from servlets through JDBC
Hi Friend,
Please visit the following links:ADS_TO_REPLACE_1
Insert Data
Delete
Data
ThanksADS_TO_REPLACE_2
how to insert checkbox value into database using jsphow to
insert checkbox value into
database using jsp
How to
insert check box value to the oracle
database using jsp?
I want to create hotel's package. where the admin will select the activities to
insert in the PACKAGE table. I
retrieve data from database using jsf retrieve
data from database using jsf Hello
I want an example of source code to retrieve
data from database
i have a
database (oracle) name as db1 it's contain table 'author' composed of three columns idauthor(primary key
how to insert checkbox value into database using jsphow to
insert checkbox value into
database using jsp
How to
insert check box value to the oracle
database using jsp?
I want to create hotel's package. where the admin will select the activities to
insert in the PACKAGE table. I
Program to read 2 integers using oops conceptsProgram to read 2 integers
using oops concepts Write a program to read two integers with the following significance.
? The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter
how to insert, retrieve data from,to db(code)....how to
insert, retrieve
data from,to db(code).... Hi.....
i ve... that
data will b stored in db(m
using sybase).
2.also hw to retrieve the
data from... validations for username, password
using javascript,hw to write that,n in wch pgm
how to insert data into databasse by using jdbchow to
insert data into databasse by
using jdbc â?¢ Create... and
insert those inputs into
database using JDBC.
Here is a jsp code that accepts several fields
from the user and add these values to
database.
1
how to insert data into databasse by using jdbchow to
insert data into databasse by
using jdbc â?¢ Create... and
insert those inputs into
database using JDBC.
Here is a jsp code that accepts several fields
from the user and add these values to
database.
1
how to insert data into databasse by using jdbchow to
insert data into databasse by
using jdbc â?¢ Create... and
insert those inputs into
database using JDBC.
Here is a jsp code that accepts several fields
from the user and add these values to
database.
1
how to insert data into databasse by using jdbchow to
insert data into databasse by
using jdbc â?¢ Create... and
insert those inputs into
database using JDBC.
Here is a jsp code that accepts several fields
from the user and add these values to
database.
1
how to insert, retrieve data from,to db(code)....how to
insert, retrieve
data from,to db(code).... Hi, i have created... register his details,(for ex,username,password,dob,gender) 1.how that
data will b stored in db(m
using sybase).
2.also hw to retrieve the
data from db. cn u
Populate a combo box using data from a databasePopulate a combo box
using data from a database Hi Guys, In need... to populate the first one, and then
how to send the
data off to a servlet and preform a search on the
database for the values I want,
but then
how do I pass that back
insert data into databaseinsert data into database hi,thanks for reply
just i am doing... and studentmaster is the
database table name.
i am
using same details.
Now give the
data into the jsp page that
data stored into the database.Here the error
retrive data from database using jsp in struts? retrive
data from database using jsp in struts? *search.jsp*
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<... searchProduct(SearchDTO sdto) {
String query="select *
from product
database is connected but not insert the datadatabase is connected but not
insert the data hi,
i am getting connected to database.Retrive the
data also but cannot
insert the
data into
database. i am
using msaccess2007.my inserstudententry.jsp code is follows,pls help me
Insert file data into databaseInsert file
data into
database
In this section, you will learn
how to
insert.... Now to
insert this
data into the
database, we have
established a
database connection. Then
using the
insert query, we have inserted
whole file
data