Java entry prog.

Ads
 

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);
        }
    }
}

Ads









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 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
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
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
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
Order Entry System
Order Entry System  Create a new order entry system using netbeans and microsoft access.can anyone help me
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'
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
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
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
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<
(ForPro) turbo C prog. Q4
(ForPro) turbo C prog. Q4  I need to learn some easy foxpro program.. for example sum,interchange, loop etc
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
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
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
Version of com.talobin>card-entry dependency
List of Version of com.talobin>card-entry dependency
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
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
ModuleNotFoundError: No module named 'data-entry-demo'
ModuleNotFoundError: No module named 'data-entry-demo'  Hi, My... named 'data-entry-demo' How to remove the ModuleNotFoundError: No module named 'data-entry-demo' error? Thanks   Hi, In your python

Ads