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



Home Answers Viewqa JDBC mysql tables
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


uma
mysql tables
2 Answer(s)      6 years and a month ago
Posted in : JDBC



Advertisement
View Answers

October 1, 2008 at 11:20 AM


Hi,

You not mention ur requirement properly mean insert or update or select or what?

I gave a sample program you have to modify as per ur field.

package rajanikant.code.oct_2008;

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

public class MySqlTest {

private Connection con = null;
private Statement stmt;
private PreparedStatement pst;

private ResultSet rs ;

public void getConnection(){
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename";, "root", "");
} catch (ClassNotFoundException e) {
System.out.println("Driver Class Not Found");
} catch (SQLException e) {
System.out.println("Connection Error");
}
}

public void myStuff(){
getConnection();

try {
stmt = con.createStatement();
rs = stmt.executeQuery(" Your Query");

pst = con.prepareStatement("Insert Into your-tablename values(?,?,?,?)" );
//depend upon "?" we have to write the following line
pst.setString(1, "value1");
pst.setString(2, "value2");
pst.setString(3, "value3");
pst.setInt(4, 6);
rs = pst.executeQuery();
} catch (SQLException e) {

}
}

public static void main(String s[]){
new MySqlTest().myStuff();
}
}


Rajanikant


October 1, 2008 at 11:27 AM


Hi,


I am sending a link. This link will help you.

Please visit for more information.

http://www.roseindia.net/jdbc/


Thanks.

Amardeep


Related Tutorials/Questions & Answers:
Different tables present in MySQL
Different tables present in MySQL  What are the different tables present in MySQL? Which type of table is generated when we are creating a table...; Hi friends, Total 5 types of tables we can create 1. MyISAM 2. Heap 3
Mysql List Tables
Mysql List Tables       The Tutorial illustrate an example from 'Mysql  List Tables'. To understand this example we use show tables query that return the list
Advertisements
mysql tables - JDBC
mysql tables  hi, I have a table in MySql, having fields, emp... mangager for MySQL, statements, preparedstatements,resultset. Please can you..."); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/databasename
mysql select from multiple tables
mysql select from multiple tables   how can i select the date field from multiple tables in mysql?   "UNION" can be used to select data from multiple tables in my sql... for example (SELECT * from name where `name
Mysql List Tables
Mysql List Tables       The Tutorial illustrate an example from 'Mysql  List Tables'. To understand this example we use show tables query that return the list
Purge Data from Mysql tables
Purge Data from Mysql tables  Hi, i have to write a mysql procedure to purge data from tables. but written procedure clear entire tables data. Please give me the solution for purging data. CREATE DEFINER=`root`@`localhost
Mysql Join 3 Tables
Mysql Join 3 Tables       Mysql Join 3 Tables is used to join 3 Tables using left join... an example from 'Mysql Join 3 Tables' using Left Join. To grasp this example
Comparing tables
Comparing tables  How to compare two or more tables in the Mysql database using jdbc
Nest tables within tables
Nest tables within tables  Can I nest tables within tables
Setting up MySQL Database and Tables
Setting up MySQL Database and Tables       I am assuming that you have running instance of MySQL Database and you know how to work with the MySQL database. To access the database
tables for layout
tables for layout  Are there any problems with using tables for layout
tables for layout
tables for layout  Are there any problems with using tables for layout
CSV tables
CSV tables  hello, What are CSV tables?   hii, CSV Tables cannot be indexed.CSV Tables are the special tables, data for which is saved into comma-separated values files
Mysql List
Mysql List       Mysql List elaborate you an Query for listing databases, tables, Procedure... illustrate an example from 'Mysql List'. To grasp this example, We show you
Mysql List
Mysql List       Mysql List elaborate you an Query for listing databases,tables... illustrate an example from 'Mysql List'. To grasp this example, We show you
tables to structure forms
tables to structure forms  How can I use tables to structure forms
tables to structure forms
tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
Mysql Alter Tables
Mysql Alter Tables This example illustrates how to alert the table and how it is used in query. In this example you will see all tables in test database....   Query show tables
program to create nested tables
program to create nested tables  program to create nested tables
Join the two tables in sql
Join the two tables in sql  How to join the two tables in SQL ..and return the value from common column in SQL Database
SQL All Tables
SQL All Tables       SQL All Tables is used to show all the tables in database. Understand with Example The Tutorial illustrate an example from 'SQL All Tables'. To understand
Joining tables using criteria
Joining tables using criteria  How do i join more than three tables and retrieve one column from parent table and count of unique values in a single column from child table,the joined tables must be maintain primary key
PL/SQL tables
PL/SQL tables   hii, Describe the use of PL/SQL tables ?   hello, PL/SQL tables are scalar arrays that can be referenced by a binary integer. They can be used to hold values for use in later queries or calculations
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Get the list of tables in Sybase
Get the list of tables in Sybase   hello, How to get the list of tables in Sybase?   hii, Select name from sysobjects where type="...." it will give You list according to where clause
types of relationships in tables
-to-many and many-to-many relationships while designing tables?   hi... tables with primary and foreign key relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign
look up tables in java
look up tables in java  cachetables , how to apply cache mecanisam in java , i have some tables which is frequently used so i want to fetch first time and want to keep in some scope untill the application end . with out hitting
PHP Join Tables
PHP Join Tables  i wanted to show the information from two or more table in PHP. How can i do it with the PHP Join Tables
 

 

 

DMCA.com