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




Have Programming Question? Ask it here!
 
 
 


pushpa
id creation
0 Answer(s)      a year and 11 months ago
Posted in : JSP-Servlet


CREATE TABLE mohan2 ( sno bigint(20) NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL, sal int(30) NOT NULL, eid varchar(30) NOT NULL, PRIMARY KEY (sno,eid) )

import java.sql.*;
import java.util.*;
public class sample3
{
 static int Generate(String name1,int t)
{
   int len=5;
   int x=0;
  Connection conn = null;
  Statement st=null;
  String url = "jdbc:mysql://localhost:3306/";
  String dbName = "test";
  String driver = "com.mysql.jdbc.Driver";
  String userName = "root"; 
  String password = "password";
  String eid="";
  try 
  {
  Class.forName(driver).newInstance();
  conn = DriverManager.getConnection(url+dbName,userName,password);
  st=conn.createStatement();
  ResultSet rs=st.executeQuery("select max(sno) from mohan2");
  rs.next();
  int s=rs.getInt(1);
  System.out.println(s);
  s=s+1;
  StringBuffer sb = new StringBuffer(len);
  sb.append("P");
  len=len-1;
  String v=String.valueOf(s);
  int p=v.length();
  len=len-p;
  while(len--!=0)
    sb.append("0");
  sb.append(v);
   eid=sb.toString();
  rs.close();
  st.close();
   st=conn.createStatement();
  x=st.executeUpdate("insert into mohan2(eid,name,sal) values('"+eid+"','"+name1+"',"+t+")"); <br />
   st.close();
   conn.close();
  }
  catch(Exception e)
  {
    e.printStackTrace();
   }
    return x;
}
public static void main(String[] args) 
   {
        Scanner s=new Scanner(System.in);
        System.out.println("Enter emp name:");
        String str=s.next();
        System.out.println("Enter emp sal:");
        int sal=s.nextInt();
        //sample3 s1=new sample3();
        int x=Generate(str,sal);
        if(x==1)
            System.out.println("Data is inserted");
       else
           System.out.println("data is not inserted");
   }
}

how can write this program in jsp its working on console but in jsp it shown internal error? how to write above code in jsp please help me i will sumbit the project in two days please sir


Advertisement
View Answers

Related Tutorials/Questions & Answers:
id creation
id creation  CREATE TABLE mohan2 ( sno bigint(20) NOT NULL AUTO_INCREMENT, name varchar(30) NOT NULL, sal int(30) NOT NULL, eid varchar(30) NOT NULL, PRIMARY KEY (sno,eid) ) import java.sql.*; import
id
id  how to find date of birth and gender in id in html with the help of javascript
Advertisements
Creation of methods
Creation of methods  I have a only single class and its having only one method ie., main method only.... i need to develop another method...:"); mobi=input.next(); System.out.println("Email Id:"); mail=input.next
Creation of xml
Creation of xml  Hi, I need to fetch details from my database and to create a xml file containing all those datas...My database datas are in key value pair... AppID Label Value 12345 Applicant name XXXX 12345 Masterno
total id
total id  how to print and total my id number ..for example if my id is 0123456789 the output will look like this : 0123456789 0+1+2+3+4+5+6+7+8+9=45 help me plz
Session ID
Session ID  How can I change the session ID of the page?   ...' session ID values because it is very likely to result in the loss of the session or with people acquiring other users' data. The session ID value should be managed
How to: generic array creation
How to: generic array creation  How to: generic array creation
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method="post" enctype="multipart/form-data" name="form1"> this action page can't get String tp = request.getParameter("indegrates"). i wrote article upload
id generation
id generation  CREATE TABLE `mohan2` ( `sno` bigint(20) NOT NULL... to employee id automatically generate please try this code, useful for u thanks ...");%> any body want to employee id automatically generate please try
object creation - Subversion
object creation in Java  In how many ways we can create objects in Java
object creation - Java Beginners
object creation  I need object creation in depth(with stack,pc registers).Any one can provide me if possible with video/audio
exe file creation - JDBC
exe file creation   hi i have done a project in java swings.project name is format migrator.means db migrator. now my aim is create EXE FILE for my project. pls do consider
creation of installer - Java Magazine
creation of installer  plz tell me how can be create installer for any developed application in java?  visit the following url izpack.org.. it will helps u
Chatbox creation problem
Chatbox creation problem  i have one chat box in my web site and i...; function showhide(id, visibility) { document.getElementById(id...', 'inline');">a div using javascript.</a> <div id="LoadPage1
Session creation and tracking
Session creation and tracking  1.Implement the information persistence across servlet destroy or servlet container start/stop. Write a servlet such that when it is stopped (either by container shutdown or servlet stop
xml file creation in java
xml file creation in java  how to create xml file in java so that input should not be given from keyboard. and that file should be stored.   Please visit the following links: http://www.roseindia.net/tutorial/java/xml
Random Creation of password
Random Creation of password  Dear Sir I have created a form with some details in it.When clicking on the submit button it gives me a password .....Details and the password is saved in the database....The password has
creation of database - SQL
creation of database  hi, where to and how to execute SQL queries?   Hi nanju mysql>CREATE DATABASE search; mysql> SHOW DATABASES; mysql> USE search mysql>create table Emp (fname VARCHAR(20
creation of a form - JSP-Servlet
creation of a form  how to create a question paper using JSP code  Hi Friend, We have taken radiobuttons in our application, you can take textarea, textfield etc. Create a table ans(ques,op1,op2,op3,op4,op5,ans
XSD Creation. - WebSevices
XSD Creation.  When I try to generate xsd from java object. It is generating XSD file finely. But the problem is it isgenerating XSD file elements in alphabetical order. can u please sujest me how can we do that one. I tried
creation button using objective c
creation button using objective c  creation button using objective c
bean creation exception
bean creation exception  hi i am getting exception while running simple spring ioc program Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class
xml creation in java
xml creation in java  HI, I need a java program to create an xml file... therez a tutorial in your site to create an xml file at http://www.roseindia.net/xml/dom/CreatXMLFile.shtml but this isn't creating a file, its just
creation of table using a Java swing
creation of table using a Java swing  how to create a table dynamically in Java swing
Session ID - Java Beginners
Session ID  Do we get new session id for a new domain after clicking..." + " Info TypeValue\n" + "\n" + " ID\n..." + " Creation Time\n" + " " + new Date
forums creation using spring with hibernate?
forums creation using spring with hibernate?  how to write mandatory fields with validations in forms using spring with hibernate? give me detailed example
PDF creation in JAVA - JSP-Servlet
PDF creation in JAVA  HI! Good morning.... I want to create pdf file and i want to write something into pdf file....before creation. Upto creation i have done but how to write data into pdf. File Writer is not working
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
php maintain session id
php maintain session id   How to maintain session ID for a user in PHP
how make ID - Ajax
how make ID  how make a ID in eyeball chat
cache creation in java - Java Beginners
cache creation in java  Hi All, I am planing to create cache in my web application. please send me the some sample code to create cache by using org.apache.oro.utils package. please help me out. Thanks, mln15584
ID number program
ID number program  hi can anyone help me with the following program. a program that can determine a person,s date of birth, age, gender and citizenship by just entering the id number. thanks in advance
id sender uibutton
id sender uibutton  Hi, I want to find which button is clicked based on the id sender when UIButton is clicked. thanks   HI, Here is the code example: UIButton* myButton = (UIButton*)sender; NSLog(@"Button tag
need to generate ID
need to generate ID  hai, i need to generate ID i.e when i select addemploye option and submit, it should generate a emp ID which is 1 greater than the previous highest ID value stored in database. eg: if the higest value
need to generate ID
need to generate ID  hai, i need to generate ID i.e when i select addemploye option and submit, it should generate a emp ID which is 1 greater than the previous highest ID value stored in database. eg: if the higest value
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate?   Here is an example - package...=session.createCriteria(Employee.class).add(Restrictions.eq("id", 1)); List<
checkbox custom tag creation in jsf
checkbox custom tag creation in jsf  how to create check box custom tags with the following functionality: 1.there must be two checkboxes 2.when the first box is checked it must populate the names of bikes,when the second
JQuery-Selecting class or ID
am getting little trouble in selecting an item using class or ID in jQuery?   Given below code selects an element of id name "element1" : $('#element1') Since IDs are unique, so it will select only the element of particular id
JQuery-Selecting class or ID
JQuery-Selecting class or ID  Hi Guys, I am new to JQuery. I am getting little trouble in selecting an item using class or ID in jQuery
Hibernate generation Id to postgreSQL
Hibernate generation Id to postgreSQL  Hi, I'm trying to implement a id generator in Hibernate, but I'm having a problem. Hibernate doesn't seems to reset the counting when the id is generated. For example: 1 - In PostgreSQL I
Auto Generated Employee ID
Auto Generated Employee ID  Hello Everyone I want to generate an ID like (SCS-0001) and then it should be auto incremented each time a new employee add page is opens. I am using My Sql database
Validate ID Number
Validate ID Number   How to validate South African ID Number using...   Here is a code that check whether the south African Id is valid...("Enter South African ID: "); String id=input.nextLine
creation an dmanipulation of trees - Java Beginners
creation an dmanipulation of trees  Hi guys? pls i want to find out a hind aboout what these terms or phrases means, -To create and manipulate a Binary Search Tree -To use the Java API's Stack in conjunction with other
validating email id
validating email id  how to validate the email id ?   <...=""; return false; } } </script> <form id="form...;tr><td>Email </td><td><input type="text" id="email" ><
delete row using id
= "delete from Insurance insurance where id = 2"; Query query = sess.createQuery...: delete [delete from pkg2.Insurance insurance where id = 2
Generate Employee ID (SCS-0001,SCS-0002......)
Generate Employee ID (SCS-0001,SCS-0002......)  Hello everyone i am beginner in java and i am working on my major project I want to generate bill number and employee number like SCS-0001 and so on and bill number like SCS/'date
Session regenerated id
Session regenerated ID session_regenerate_id() works to regenerate the session... the session_regenrateid and set this id to new sessionid. <?php session_start..._id(); echo "Old Session:". $oldsessionid."<br />"
Creation of MultiThreads
Creation of Multiple Threads       Like creation of a single thread, You can also create more than one thread (multithreads) in a program using class Thread
Creation of MultiThreads
Creation of MultiThreads       Like creation of a single thread, You can also create more than one thread (multithreads) in a program using class Thread or implementing interface
Advertisements
 

 

 

DMCA.com