id creation

Ads
 

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 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

View Answers

Ads









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
How to: generic array creation
How to: generic array creation  How to: generic array creation
object creation - Subversion
object creation in Java  In how many ways we can create objects in Java
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
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
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
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
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
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
<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
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'music-album-creation'
ModuleNotFoundError: No module named 'music-album-creation'  Hi...: No module named 'music-album-creation' How to remove the ModuleNotFoundError: No module named 'music-album-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'xseed-max-box-creation'
ModuleNotFoundError: No module named 'xseed-max-box-creation'  Hi...: No module named 'xseed-max-box-creation' How to remove the ModuleNotFoundError: No module named 'xseed-max-box-creation' error? Thanks   Hi
ModuleNotFoundError: No module named 'xseed-minicampus-creation'
ModuleNotFoundError: No module named 'xseed-minicampus-creation'  Hi...: No module named 'xseed-minicampus-creation' How to remove the ModuleNotFoundError: No module named 'xseed-minicampus-creation' error? Thanks  
dynamic creation of multiple drop-down menus
dynamic creation of multiple drop-down menus  can anybody plz help me in coding for dynamic creation of multiple drop-down menus in a webpage using ajax/js/html/css
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
Intranet Website creation - plz help me
Intranet Website creation - plz help me   hi.. I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different .. can anybody pls help me
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
php maintain session id
php maintain session id   How to maintain session ID for a user in PHP
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
ModuleNotFoundError: No module named 'id'
ModuleNotFoundError: No module named 'id'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'id' How to remove the ModuleNotFoundError: No module named 'id' error
How to get Button Id ?
How to get Button Id ?  How to get Button ID instead of its value in Servlet. (I am not using jsp right now
Core java interview question, object creation.
Core java interview question, object creation.  How can we restrict to create objects for more than five? That means i want only 5 objects, how to restrict to create 6th objects
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

Ads