Rama Kant Tibrewal
Java entry prog.
1 Answer(s)      4 years ago
Posted in : JavaScript Questions

Dear sir

I will enter the dept code, dept name and insert into dept_mast and save. Pl.

Dept_code   Char(2) Primary key (no duplicate key allowed)      
Dept_name   Char(25)        

  **Entry screen**

**Department entry**            

Dept Code : -----   (Check Duplicate not allowed)       
Name        : --------------------          

Message :           
View Answers

August 8, 2011 at 12:41 PM

import java.util.*;
import java.sql.*;
class InsertData{
    public static void main(String[] args){
           Scanner input=new Scanner(System.in);
           System.out.print("DEPT Code: ");
           String code=input.nextLine();
           System.out.print("DEPT Name: ");
           String name=input.nextLine();

           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("Select * from dept where DEPT_NO='"+code+"'");
           int count=0;
               System.out.println("Error! Your dept code is not valid!");
           st.executeUpdate("insert into dept(DEPT_NO,DEPT_NAME) values('"+code+"','"+name+"')");
           System.out.println("Data is successfully inserted!");
        catch(Exception e){

Related Tutorials/Questions & Answers:
Java entry prog.
Java entry prog.  Dear sir I will enter the dept code, dept name and insert into dept_mast and save. Pl. Dept_mast Dept_code Char(2...) **Entry screen** **Department entry** Dept Code
java prog
java prog  find out a string from the collection of string in java
java prog
java prog  write a java program to accept a file name as command line argument.Append the string "file modified by program" to the end of the same file and print the contents of the modified file
java prog
java prog  Write a Java applet that inputs a person's date of birth (month, day, year): ā?¢ Informs the person if the year of birth is a prime number. ā?¢ Informs the person if the year of birth is a leap year. ā?¢ Computes
java prog que
java prog que  create a class that returns the reverse of each word in the given string. For example if we give "who are u?" as input, it should return "ohw era u
servlet prog - Java Interview Questions
servlet to jsp? how a thread or request pass from one servlet prog to one jsp prog? is it possible of communicating from servlet to jsp prog? please explain briefly with one java code example? Thanks in advance
Java prog - Java Beginners
Java prog  Write a program on Java that ask the user to input: Cost of Machine, Life of Machine, Cost of capital in Percentage, in an JOption pane window and that calculates and outputs Annual Lease rent.  Hi friend i
java applet prog
java applet prog  applet to display scrolling text from right to left in an applet window using thread. text should be accepted by html parameter
Validating Duplicate Entry To Database - Java Beginners
Validating Duplicate Entry To Database  I have a servlet that adds data to the table called foodtype in (Ms Access). i already have Chinese, vegetarian entered in table. what am trying to do is to validate when entering foodtypes
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a hashtable with some student hall ticket numbers and their results. when we type a hallticket number,it shud display the results? please provide the detail java code for this? thanks in advance
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a Hashtable with some students hall ticket numbers and their results. when you type a hall tickets number,it shud display the results? please provide the java code detaily for this query?thanks
Create a deque linked list of Entry Objects - Java Beginners
Create a deque linked list of Entry Objects  I need to know if I have successfully created a Square Matrix List of Entry Objects. The detail desciption and my java code solution follows: A) Description 1) The List ADT
NEED A PROG   whats the program to add,delete, display elements of an object using collecions. without using linked list   Hi Friend, Try the following code: import java.util.*; class CollectionExample { public
turbo C prog.
turbo C prog.  Is is possible print ASCII value of a alphabets using turbo C prog
delete an entry using JavaScript
delete an entry using JavaScript  How to delete an entry using JavaScript
database entry using jdbc
database entry using jdbc  Give me a program to enter records in table using jdbc in java.   Hi Friend, Please visit the following link: Insert data into database Thanks
Order Entry System
Order Entry System  Create a new order entry system using netbeans and microsoft access.can anyone help me
Edit cron entry
Edit cron entry   Hi, What is the command to Edit cron entry in linux? Regards Deepak Kumar   Hi, You can use the following command to open cron configuration in vi editor: crontab -e After editing just save
question "writing prog"
question "writing prog"  Hello I want helping for this question, please Write a program that reads some friendsā?? names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
Solution to C prog
Solution to C prog   Hi, Pls any body help, why the following prog crashing while running. #include<stdio.h> #include<conio.h> int main(){ int n,*fact(int *n); printf("Enter the number:"); scanf
make a prog for this query
make a prog for this query  write a program implementing interface for personal data n salary details. interface must contain abstract methods. steps for the program are 1) store the data in text file 2)display salary when emp id
turbo C prog.
turbo C prog.  Is it possible to print ASCII value A to Z with out using scan ? also give to simple example of binary search ...   #include<stdio.h> #include<conio.h> void main() { for(char c='A';c<
turbo C prog. Q3
turbo C prog. Q3  What is the difference between if and ladder if ? Describe ladder if with example. What is the purpose of the parameter passing ? please Describe with example.   if statement is used to write
Prog Error - JSP-Servlet
Prog Error   Place Ad function Browse() { Advertisement Management System Create Ad State: City: Main Category: Sub Category: Title
How to search entry in ZipFile.
:\>java SearchEntry Entry name bharat.txt is found. Download...How to search entry in ZipFile. In this tutorial, We will discuss the use... will search given entry in a zip file. The getEntry method search
(ForPro) turbo C prog. Q4
(ForPro) turbo C prog. Q4  I need to learn some easy foxpro program.. for example sum,interchange, loop etc
Inserting a New Entry in a List
Inserting a New Entry in a List       This Example shows you how to Insert a new Entry in a list  in a DOM document. JAXP (Java API for XML Processing) is an interface which
Spring Hello World prog - Spring
Spring Hello World prog  I used running the helloworld prog code mentioned in http://www.vaannila.com/spring/spring-mvc-tutorial-1.html I'm getting null pointer exception. as shown below. I added all the jars and my
select maximum time entry row - JDBC
select maximum time entry row  Hi fried you given ans this Sql Query for select maximum value max() function use. "select max(fieldname... is maximum time entry in column Status please if you have any other query