database is connected but not insert the data

Ads
 

database 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

<%@page language="java" import="java.sql.*" import = "java.util.*" import = "java.io.*" import = "java.sql.*" import = "java.lang.*" import = "javax.servlet.*" import = "java.text.*"

%>

<%! String removeNull(String str) { if(str==null) return ""; else return str; } %> <%int i=0; String msgsuccess=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:Driver={Microsoft Access Driver " + "(*.mdb, *.accdb)};DBQ=C:\stud.accdb"; Connection con = DriverManager.getConnection(url); out.println("Connected!"); Statement st=con.createStatement();

    String name=removeNull(request.getParameter("stuname"));
    String phno=removeNull(request.getParameter("stuphone"));
    String addr=removeNull(request.getParameter("stuadd"));
    String sec=removeNull(request.getParameter("stusec"));
    String strSTUNO="select (max(sno)+1) as ssno from studentmaster where status='"+sec+"'" ;
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery(strSTUNO);
    String stuno="";
    String stuno1="";
    out.println(strSTUNO);
    while(rs.next())
    {
        stuno=removeNull(rs.getString("ssno"));
    }


    SimpleDateFormat sdfd=new SimpleDateFormat("dd/MM/yyyy");
    java.util.Date dt1= new java.util.Date();
     String dt=sdfd.format(dt1);
    String batch=dt.substring(6,10)+sec+"T";
    out.println(batch); 
    stuno1=batch+stuno;

    //PreparedStatement pst=con.prepareStatement("insert into studentmaster(slno) values('"+batch+"')");
    i=st.executeUpdate("insert into studentmaster(slno) values('"+batch+"')");
    out.println(i);
    if(i!=0)
    {
     msgsuccess=" Record Inserted Successfully...";
     request.setAttribute("msgsuccess",msgsuccess);
     //con.commit();
     con.close();
     //System.out.println("Private DTR "+dtrcode+" Inserted Successfully");
     response.sendRedirect("studententry.jsp?msgsuccess="+msgsuccess);
    }

%>

<%} catch(Exception e) { throw e; }

%>

View Answers

February 24, 2011 at 1:09 PM

What do you wanted to do through this page? Your problem is not clear to us.Please specify some details.

Ads









Related Tutorials/Questions & Answers:
database is connected but not insert the data
database 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... = DriverManager.getConnection(url); out.println("Connected!"); Statement st
insert data into database
insert 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
Advertisements
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
insert data into database
insert data into database  type Exception report message...)Go to the start->Control Panel->Administrative Tools-> data sources. 2... selecting the driver, click finish button. 4)Then give Data Source Name
insert data in the database using checkbox
insert 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
Question about "Insert text file data into Database"
Question about "Insert text file data into Database"  Hey I was reading the tutorial "Insert text file data into Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
how to insert data into database using jsp & retrive
how 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
what is the jsp coding to insert a data in database tables
what is the jsp coding to insert a data in database tables  Dear Sir, I Want to know the coding for insert the data from jsp to oracle database.. my... that insert the form values to MySQL database. 1)register.jsp: <html> <form
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... and database name. Here machine name id localhost and database name... = null; // declare a resultset that uses as a table for output data from
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
Insert XML file data to database
Insert XML file data to database In this tutorial, you will learn how to insert the xml file data to database using dom parser. You all are aware of XML... to read the xml file data and save the values of an XML file to a Database
using ajax i want to insert data into oracle database
using ajax i want to insert data into oracle database  i would like to insert/update/select/delete from jsp to oracle database using ajax? please send a code for this iam using oracl database thank you
How to insert data from textfields into database using hibernate?
How to insert data from textfields into database using hibernate?   try{ Session session = HibernateUtil.getSessionFactory().openSession...); System.out.println("Successfully data insert in database"); tx.commit
java script unable to connect to oracle database and insert data
is to insert data from jsp to oracle database 8, so i create a table in oracle...java script unable to connect to oracle database and insert data  ...=con.createStatement(); int i=st.executeUpdate("insert into departments
How to Insert image and data both together in database in JSP/Servlet ?
How to Insert image and data both together in database in JSP/Servlet ? ... = connection.prepareStatement("insert into data(Name,City,Img) values('"+nn+"','"+cc...;BODY> <FORM ENCTYPE="multipart/form-data" ACTION
callable statement,stored procedure for insert data and also for update data into oracle database using jsp
callable statement,stored procedure for insert data and also for update data into oracle database using jsp  iam a fresher newbie to softparsing i... procedure for inserting data into oracle database as bind variable and same
JDBC Video Tutorial- How to insert data into MySQL database table?
JDBC Video tutorial example for inserting data into MySQL database JDBC... and in this video I have explained the steps of write code to insert the data...; to insert the database into database. The executeUpdate() method
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can you help me out !!.......i wanna to know the appropriate java syntax to insert data into database using an drop down box .....as i m using eclipse as jdbc
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can you help me out !!.......i wanna to know the appropriate java syntax to insert data into database using an drop down box .....as i m using eclipse as jdbc
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can you help me out !!.......i wanna to know the appropriate java syntax to insert data into database using an drop down box .....as i m using eclipse as jdbc
insert data using drop down box in java into database postgresql
insert data using drop down box in java into database postgresql  can you help me out !!.......i wanna to know the appropriate java syntax to insert data into database using an drop down box .....as i m using eclipse as jdbc
applet connected to table in MS Access database
applet connected to table in MS Access database   i have connected my...(); //insert data insertData(); //use precompiled statement to update data...()); } } //insert data to table COFFEES static void insertData() { try
How to insert multiple drop down list data in single column in sql database using servlet
How to insert multiple drop down list data in single column in sql database using servlet  i want to insert date of birth of user by using separate drop down list box for year,month and day into dateofbirth column in sql server
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database... a browse button which can upload a excelfile and after uploading the data should be inserted into oracle database.. please help me sir...   hi friend
single query to insert the data
single query to insert the data  How to insert data for all HTML fields in single MYSQL query
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it   I have tried the following code Database creation: create database studentdb; create table stu_info ( ID int not null auto
Insert image in database
Insert image in database  Want a jsp-struts program in which the imageFile is in the form of getter and setter and inserted in the database as a Blob using . and then download the image and show on next jsp pg. No use
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it
Insert data in mysql database through jsp using Prepared Statement ---- Please Resolve it   I have tried the following code Database creation: create database studentdb; create table stu_info ( ID int not null auto

Ads