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) 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){
        try{
           Scanner input=new Scanner(System.in);
           System.out.print("DEPT Code: ");
           String code=input.nextLine();
           System.out.print("DEPT Name: ");
           String name=input.nextLine();

           Class.forName("com.mysql.jdbc.Driver");
           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;
           while(rs.next()){
               count++;
           }
           if(count>0){
               System.out.println("Error! Your dept code is not valid!");
           }
           else{
           st.executeUpdate("insert into dept(DEPT_NO,DEPT_NAME) values('"+code+"','"+name+"')");
           System.out.println("Data is successfully inserted!");
           }
        }
        catch(Exception e){
         System.out.println(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
Advertisements
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
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
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
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
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
Maven dependency for com.talobin - card-entry version 0.1.2 is released. Learn to use card-entry version 0.1.2 in Maven based Java projects
this version ( com.talobin - card-entry version 0.1.2 ) in their Java project... in project? Steps to use  com.talobin - card-entry version 0.1.2 in Java...; com.talobin - card-entry version 0.1.2 java library in your project. ADS
Maven dependency for com.talobin - card-entry version 0.1.0 is released. Learn to use card-entry version 0.1.0 in Maven based Java projects
this version ( com.talobin - card-entry version 0.1.0 ) in their Java project... that downloads and includes  com.talobin - card-entry version 0.1.0 java...Maven dependency for  com.talobin  - Version 0.1.0 of card-entry
ModuleNotFoundError: No module named 'prog'
ModuleNotFoundError: No module named 'prog'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'prog' How to remove the ModuleNotFoundError: No module named 'prog' error
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:ADS_TO_REPLACE_1 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
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
please help me in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
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
ModuleNotFoundError: No module named 'func_prog'
ModuleNotFoundError: No module named 'func_prog'  Hi, My Python... 'func_prog' How to remove the ModuleNotFoundError: No module named 'func_prog' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'entry'
ModuleNotFoundError: No module named 'entry'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'entry' How to remove the ModuleNotFoundError: No module named 'entry'
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<
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
Prog Error - JSP-Servlet
Prog Error   Place Ad function Browse() { Advertisement Management System Create Ad State: City: Main Category: Sub Category: Title
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
(ForPro) turbo C prog. Q4
(ForPro) turbo C prog. Q4  I need to learn some easy foxpro program.. for example sum,interchange, loop etc
entry data science jobs
entry data science jobs  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: entry data... the topic "entry data science jobs". Also tell me which is the good
data science entry jobs
data science entry jobs  Hi, I am beginner in Data Science... entry jobs Try to provide me good examples or tutorials links so that I can learn the topic "data science entry jobs". Also tell me which is the good
ModuleNotFoundError: No module named 'prog-edu-assistant-tools'
ModuleNotFoundError: No module named 'prog-edu-assistant-tools'  Hi...: No module named 'prog-edu-assistant-tools' How to remove the ModuleNotFoundError: No module named 'prog-edu-assistant-tools' error? Thanks  
ModuleNotFoundError: No module named 'prog_lang_detector'
ModuleNotFoundError: No module named 'prog_lang_detector'  Hi, My... named 'prog_lang_detector' How to remove the ModuleNotFoundError: No module named 'prog_lang_detector' error? Thanks   Hi, In your
How to search entry in ZipFile.
C:\>java SearchEntry Entry name bharat.txt is found...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
ModuleNotFoundError: No module named 'masonite-entry'
ModuleNotFoundError: No module named 'masonite-entry'  Hi, My... named 'masonite-entry' How to remove the ModuleNotFoundError: No module named 'masonite-entry' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'openregister-entry'
ModuleNotFoundError: No module named 'openregister-entry'  Hi, My... named 'openregister-entry' How to remove the ModuleNotFoundError: No module named 'openregister-entry' error? Thanks   Hi, In your
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry version 0.1.5
-entry:0.1.5 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for card-entry version 0.1.5...Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry version 0.1.4
-entry:0.1.4 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for card-entry version 0.1.4...Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry version 0.1.3
-entry:0.1.3 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for card-entry version 0.1.3...Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry version 0.1.2
-entry:0.1.2 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for card-entry version 0.1.2...Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry version 0.1.1
-entry:0.1.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for card-entry version 0.1.1...Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry version 0.1.0
-entry:0.1.0 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for card-entry version 0.1.0...Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for card-entry
Version of com.talobin>card-entry dependency
List of Version of com.talobin>card-entry dependency
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
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks
PKG_PROG_PKG_CONFIG: command not found
PKG_PROG_PKG_CONFIG: command not found  Hi, How to solve PKGPROGPKG_CONFIG: command not found error This error is coming while executing the configure script. Thanks

Ads