Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC jdbc insert
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vanchinathan R
jdbc insert
1 Answer(s)      2 years and 3 months ago
Posted in : JDBC


Hi , i want to insert a declared integer variable into a mysql table through jdbc. how to insert that. help me with query... thanks in advance


Advertisement
View Answers

September 5, 2012 at 5:46 PM


Here is a java code that connects to database and create a table there. After creating a table in database, it insert a rows in the database.

import java.sql.*;
class ExecuteSqlQuery {
 public static void main(String[] args) {
  try {
  Class.forName("com.mysql.jdbc.Driver").newInstance();
  Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
  Statement st=con.createStatement();
  String str = "CREATE TABLE user(id INTEGER, " + "name VARCHAR(25), address VARCHAR(100), primary key(id))";
  st.executeUpdate(str);
  System.out.println("Table is created into the database.");
  st.executeUpdate("insert into user(id,name,address) values(1111,'roseindia','Rohini,Delhi')");
  System.out.println("Row is inserted.");
   st.close();
  con.close();
  } 
   catch (Exception ex) {
  System.out.println("Unable to connect to database.");
  }
  }
}


Related Tutorials/Questions & Answers:
jdbc insert
jdbc insert  Hi , i want to insert a declared integer variable into a mysql table through jdbc. how to insert that. help me with query... thanks... a table there. After creating a table in database, it insert a rows in the database
JDBC insert that returns primary key
JDBC insert that returns primary key  How to write code for jdbc insert that returns primary key? Help me fast Thanks   Hi, Following code can be used: //Add record into database String queryInsert = "insert
Advertisements
JDBC Prepared Statement Insert
JDBC Prepared Statement Insert       The Tutorial illustrates a program in JDBC Prepared Statement Insert. In this Tutorial  the code describe the include a class
oracle insert statement error - JDBC
oracle insert statement error  hi.. please help me to insert a image into oracle 11g database and please say me how can i insert image from directory like G:\imagefolder\ultrasoundimage\02us02.jpeg please help me
Jdbc Insert Statement
JDBC Insert Statement       Add a row to a existing table using insert statement in JDBC. The tutorial illustrates an example from JDBC Insert Statement. In this program
JDBC: Insert Records Example
JDBC: Insert Records Example In this section, you will learn how to insert records to the table using JDBC API. Insert Records : After creating table you can insert records. Inserting records means adding values to your table which
JDBC Insert Record
JDBC Insert Record       The Tutorial wants to explain a code that describe a JDBC Insert.... In JDBC,Statement object perform an insert record using  batch updates
JDBC Insert Statement Example
.style1 { text-align: center; } JDBC Insert Statement Example JDBC Insert statement allow you to insert record into the table of the database... the database and insert record to the database. At first create table named student
how to insert date&time coloumn value in mssql - JDBC
how to insert date&time coloumn value in mssql  how to insert...; Hi friend, Code insert date and time in Database : <% int val=0; Connection con=null; PreparedStatement pstatement = null; String url = "jdbc
JDBC batch insert
JDBC batch insert       JDBC Batch Insert is a set of SQL Statements sent to the database and executed... to carry out JDBC Batch Insert are as follows -    Driver
JDBC Insert Preparedstatement
JDBC Insert Preparedstatement     ... want to describe you a code that helps you in understanding JDBC Insert Prepared Statement. For this we have a class Jdbc Insert Prepared statement, Inside
how to insert data into databasse by using jdbc
and insert those inputs into database using JDBC.   Here is a jsp code...how to insert data into databasse by using jdbc  ? Create...("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement
how to insert data into databasse by using jdbc
and insert those inputs into database using JDBC.   Here is a jsp code...how to insert data into databasse by using jdbc  ? Create...("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement
how to insert data into databasse by using jdbc
and insert those inputs into database using JDBC.   Here is a jsp code...how to insert data into databasse by using jdbc  ? Create...("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement
how to insert data into databasse by using jdbc
and insert those inputs into database using JDBC.   Here is a jsp code...how to insert data into databasse by using jdbc  ? Create...("jdbc:mysql://localhost:3306/roseindia", "root", "root"); Statement
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m working in a project where we have to capture an image using web cam. when... , the image column is of varchar datatype.. plz can you tell me how to insert image's
Insert option does not work in my jstl... - JDBC
Insert option does not work in my jstl...  I have problem with this jstl code... This will extract and displays details from xml... But i cant able to store that values in a database... Pls solve my problem...... Joe
JDBC batch insert using Java bean class
In this tutorial, you will learn about JDBC batch insert using java bean / model class
insert
insert  insert data in database from servlet through JDBC   Ho Friend, Please visit the following: Insert data into database Thanks
JDBC Batch Example With SQL Insert Statement
JDBC Batch Example With SQL Insert Statement: In this tutorial, we are discuss about insert SQL statement with the jdbc batch. First of all, we...;com.mysql.jdbc.Driver"); connection = DriverManager.getConnection ("jdbc
can i insert values into two tables by a query - JDBC
can i insert values into two tables by a query  hi all, can i insert values into two tables by a query Thanks Bala k
JDBC Insert Prepared Statement
; } JDBC Insert PreparedStatement PreparedStatement represents..., PRIMARY KEY (`rollno`) ) following is an example of JDBC PreparedStatement... Insert PreparedStatement Example."); Connection conn = null; PreparedStatement
JDBC: Batch Insert Example
JDBC: Batch Insert Example In this tutorial, you will learn how to do batch insertion of records using JDBC API. Batch Insert : When you want to insert... insertion concept. We can insert multiple rows using single connection
JDBC Insert Null
JDBC Insert Null      ... in understanding JDBC Insert Null. The program include a class JDBC Insert Null... ( ) method set the value into the column of Employee table.  The INSERT
JDBC: Insert Record using Prepared Statements
JDBC: Insert Record using Prepared Statements In this section, you will learn how to insert row using Prepared Statements. Insert Record  ... performance. So if you want to insert many rows ,use PreparedStatement in place
Jdbc
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
JDBC Tutorial - Writing first JDBC example and running in Eclipse
How to create your first JDBC Example? Beginners in JDBC will first learn how to write simple JDBC program to connection to database and then perform insert... to insert the data into database.  Download the source code of JDBC Example
jdbc
jdbc  hi..i want to create a table and insert data in that table... using jdbc connection   import java.sql.*; public class CreateTable... = DriverManager.getConnection("jdbc:odbc:student"); Class.forName
insert and delete a row programmatically
insert and delete a row programmatically  How to insert and delete a row programmatically ? (new feature in JDBC 2.0
JDBC
JDBC save a data in the database  I need a code to save a data... between java and mysql using JDBC and saves the data into the database. import... con = null; String url = "jdbc:mysql://localhost:3306/"; String db
JDBC
JDBC code to save a data in the database  I need a code to save... the connection between java and mysql using JDBC and saves the data into the database...!"); Connection con = null; String url = "jdbc:mysql://localhost:3306/"; String db
 

 

 

DMCA.com