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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ragini Shukla
sqqqq
1 Answer(s)      6 years and 3 months ago
Posted in : Java Beginners



Advertisement
View Answers

October 10, 2008 at 5:51 PM


Hi friend,



<%@ page language="java" import="java.sql.*;"%>
<%

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "databasename";
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String userPassword = "root";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);

Statement stcount1 = conn.createStatement();
String strQuery1 = "insert into sales_transaction set vend_name='"+vend_name+"',warehouse_location='"+warehouse_location+"',reference_no='"+reference_no+"',invoice_no='"+invoice_no+"',invoice_date='"+invoice_date+"',lpo_no='"+lpo_no+"',lpo_no='"+lpo_no+"',lpo_date='"+lpo_date+"'";

int i1 = stcount1.executeUpdate(strQuery1);
Statement stcount2 = conn.createStatement();
String strQuery2 = "insert into sales_line set prod_id="+prod_id+",packing='"+packing+"',rate="+rate+",qty="+qty+",amount="+amount;
int i2 = stcount2.executeUpdate(strQuery2);

}
catch(Exception e)
{
out.println(e.getMessage());
}
%>

For more information on JDBC-Mysql visit to :
http://www.roseindia.net/jdbc/

Thanks


Related Tutorials/Questions & Answers:
 

 

 

DMCA.com