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
Related Tutorials/Questions & Answers:
id creationid 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
Creation of methodsCreation 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
Advertisements
Creation of xmlCreation 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
idid how to find date of birth and gender in
id in html with the help of javascript
creation of installer - Java Magazinecreation 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
exe file creation - JDBCexe 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
Chatbox creation problemChatbox
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
XSD Creation. - WebSevicesXSD
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 of a form - JSP-Servletcreation 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
creation of database - SQLcreation 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
Random Creation of passwordRandom
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 javaxml 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 trackingSession
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 exceptionbean
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 javaxml
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.shtmlADS_TO_REPLACE_1
but this isn't creating
PDF creation in JAVA - JSP-ServletPDF
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
cache creation in java - Java Beginnerscache
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
checkbox custom tag creation in jsfcheckbox 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
creation an dmanipulation of trees - Java Beginnerscreation 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
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
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
validte method call upon ActionForm creation.validte method call upon ActionForm
creation. I want to know if validate method is called when ActionForm object is created?
Hi,
The validate method is not called when ActionForm object is created.ADS_TO_REPLACE_1
Limit the Class Object CreationLimit the Class Object
Creation
In this section you will learn about how a class object
creation can be a
restricted to a fix number of times... to restrict the object
creation of a class. This is a simple code in Java
where I have
Cache creation using java - Java BeginnersCache
creation using java Hi All,
I am developing a web application, I have a plan to use cache in that application. I used jsp caching with the help of jsp taglib. But I want to write code in a java class,not in the jsp
help regarding creation of last year projecthelp regarding
creation of last year project i dont know whether i picked up the right category or not. actually m a last year bsc it student. i want to develop a website I-NAVIGATOR like the m-indicator mobile app. i want
How to limit object creation in Java?How to limit the max no of objects
creation for a class?
Yes there is a way in Java for limiting the no of object
creation. In this
tutorial we are going... the objects in JVM.
In this section you will learn about how a class object
creation can
How to limit object creation in Java?How to limit the max no of objects
creation for a class?
Yes there is a way in Java for limiting the no of object
creation. In this
tutorial we are going... the objects in JVM.
In this section you will learn about how a class object
creation can