Home Answers Viewqa JDBC About java and JDBC

 
 


Pradeepcb
About java and JDBC
2 Answer(s)      a year and 4 months ago
Posted in : JDBC

Hello sir, I am doing project on java thats on swings,and using the dbase as MSSQL. what i want to know is i had created a name ,textfield ,calender(for DObirth selection), this is displayed in GUI window.

Then i had created a table of Patient name ,DOBirth fields in MSSQL.Here assume three to four names are present.Has of now i had dispalyed a table in GUI window using jdbc-odbc separate program i had written. Now what i want is after displaying only Patient name (label),and calender and search button,.By clicking the search after giving name and DOBirth, it has to display only according there respective Patient details how to achieve it sir.

Plz help me in this regard.

Thanks & Regards Pradeep CBZ

View Answers

January 9, 2012 at 1:29 PM


import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;

class DatePicker {
    int month = java.util.Calendar.getInstance().get(java.util.Calendar.MONTH);
    int year = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR);;
    JLabel l = new JLabel("", JLabel.CENTER);
    String day = "";
    JDialog d;
    JButton[] button = new JButton[49];

    public DatePicker(JFrame parent) {
        d = new JDialog();
        d.setModal(true);
        String[] header = { "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };
        JPanel p1 = new JPanel(new GridLayout(7, 7));
        p1.setPreferredSize(new Dimension(430, 120));

        for (int x = 0; x < button.length; x++) {
            final int selection = x;
            button[x] = new JButton();
            button[x].setFocusPainted(false);
            button[x].setBackground(Color.white);
            if (x > 6)
                button[x].addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        day = button[selection].getActionCommand();
                        d.dispose();
                    }
                });
            if (x < 7) {
                button[x].setText(header[x]);
                button[x].setForeground(Color.red);
            }
            p1.add(button[x]);
        }
        JPanel p2 = new JPanel(new GridLayout(1, 3));
        JButton previous = new JButton("<< Previous");
        previous.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                month--;
                displayDate();
            }
        });
        p2.add(previous);
        p2.add(l);
        JButton next = new JButton("Next >>");
        next.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                month++;
                displayDate();
            }
        });
        p2.add(next);
        d.add(p1, BorderLayout.CENTER);
        d.add(p2, BorderLayout.SOUTH);
        d.pack();
        d.setLocationRelativeTo(parent);
        displayDate();
        d.setVisible(true);
    }

    public void displayDate() {
        for (int x = 7; x < button.length; x++)
            button[x].setText("");
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "MMMM yyyy");
        java.util.Calendar cal = java.util.Calendar.getInstance();
        cal.set(year, month, 1);
        int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
        int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
        for (int x = 6 + dayOfWeek, day = 1; day <= daysInMonth; x++, day++)
            button[x].setText("" + day);
        l.setText(sdf.format(cal.getTime()));
        d.setTitle("Date Picker");
    }

    public String setPickedDate() {
        if (day.equals(""))
            return day;
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy");
        java.util.Calendar cal = java.util.Calendar.getInstance();
        cal.set(year, month, Integer.parseInt(day));
        return sdf.format(cal.getTime());
    }
}

January 9, 2012 at 1:29 PM


continue....

class SearchPatientInformation {
    public static void main(String[] args) {
        JLabel lab=new JLabel("Patient Name:");
        JLabel label = new JLabel("Date of Birth:");
        final JTextField t=new JTextField(20);
        final JTextField text = new JTextField(20);
        JButton b = new JButton("Search");
        JPanel p = new JPanel(new GridLayout(3,2));
        p.add(lab);
        p.add(t);
        p.add(label);
        p.add(text);
        p.add(b);
        final JFrame f = new JFrame();
        f.getContentPane().add(p);
        f.pack();
        f.setVisible(true);
        text.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent ae) {
                text.setText(new DatePicker(f).setPickedDate());
            }
        });
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            String name=t.getText();
            String dob=text.getText();
            try{
           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 patient where patientName='"+name+"' and dob='"+dob+"'");
           String n="",d="",email="",address="";
           int contact=0;
           if(rs.next()){
               n=rs.getString("patientName");
               d=rs.getString("dob");
               email=rs.getString("email");
               address=rs.getString("address");
               contact=rs.getInt("contactNo");
           }
           String data[]={n,address,Integer.toString(contact),email,d};
           JFrame f=new JFrame();
           JPanel p=new JPanel(new GridLayout(5,2));
           String labels[]={"Patient Name","Address","Contact No","Email","Date Of Birth"};
           JLabel l[]=new JLabel[5];
           JTextField text[]=new JTextField[5];
            for(int i=0;i<5;i++){
                l[i]=new JLabel(labels[i]);
                text[i]=new JTextField(20);
                p.add(l[i]);
                p.add(text[i]);
                text[i].setText(data[i]);
                text[i].setEnabled(false);
            }
            f.add(p);
            f.setVisible(true);
            f.pack();

            }
            catch(Exception ex){}
            }
        });
    }
}









Related Pages:
about jdbc - JDBC
about jdbc  Hello folks, I am very new JDBC. I am doing a project on java messaging service on the part of the project we are using JDBC. In my project i am having two tables one is"person" table and other is"student" table  
About java and JDBC
About java and JDBC  Hello sir, I am doing project on java... in GUI window using jdbc-odbc separate program i had written. Now what i want...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc
About java and JDBC
About java and JDBC  Hello sir, I am doing project on java... in GUI window using jdbc-odbc separate program i had written. Now what i want...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc
about value taken in java database - JDBC
about value taken in java database  how to take value from Serial port communication Hyperterminal to the java database
jdbc - JDBC
drivers for concurrent access?   Question: Is the JDBC-ODBC Bridge multi-threaded? Answer: No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods
About java
About java   how we insert our database data into the jTable in java... in java   Hi Friend, Try the following code: import java.io.*; import...("jdbc:mysql://localhost:3306/test", "root", "root"); Statement st
get information about foreign keys - JDBC
get information about foreign keys  How to get the information about foreign keys in Java
about jdbc - JDBC
about jdbc  Hi folks, my previous question was when "i have a table with primary key then when i enter a value which is already there will cause a problem how to solve it." i know to retrieve all the attributes
java - JDBC
automatically loaded. The driver is loaded by calling the Class.forName() method. JDBC drivers are designed to tell the DriverManager about themselves automatically when... on JDBC visit to : http://www.roseindia.net/jdbc/understanding-driver
java - JDBC
these driver manager classes are belongs to Jdbcapi,What about Odbc?  Hi friend, The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge
About MYSQL
About MYSQL  is it possible to upload the video on mysql database   1)page.jsp: <%@ page language="java" %> <HTML> <... connectionURL = "jdbc:mysql://localhost:3306/test"; ResultSet rs = null
About springs - JDBC
About springs  Hi, My xml code is as follows :In this i have my id stored in results1(in tag). And now
jdbc
jdbc   how to write program to save data and retrieve data from the form in Java
JDBC
JDBC  how to set classpath for eclipse, java, where to copy jdbc connector
Jdbc
Jdbc  A java program with jdbc connectivity with insert,delete,update options for name,regno,mark1,mark2,total
jdbc
links: http://www.roseindia.net/jdbc/Jdbc-batch-update.shtml http://www.roseindia.net/tutorial/java/jdbc/batchupdateresultsetexample.html...jdbc define batch updates  define batch updates?exp   JDBC
About RoseIndia.net
About RoseIndia.Net RoseIndia.Net  is global services .... Our technical teams skills include Java (J2EE) programming, ASP, C#, PHP...: Java2EE - JMS, JSP, Servlets, EJB, JNDI, JDBC, Hibernate, Struts, Spring, .Net
JDBC
between java and mysql using JDBC and saves the data into the database. import...JDBC save a data in the database  I need a code to save a data... con = null; String url = "jdbc:mysql://localhost:3306/"; String db
JDBC
the connection between java and mysql using JDBC and saves the data into the database...JDBC code to save a data in the database  I need a code to save...!"); Connection con = null; String url = "jdbc:mysql://localhost:3306/"; String db
JDBC Training, Learn JDBC yourself
- Learn about JDBC with small examples JDBC... - Learn about JDBC 4.0 Here are more tutorials you can learn: What... JDBC Connection Pooling Accessing Database using Java and JDBC Learn how
jdbc - JDBC
Java JDBC application  Database Application in Java JDBC
jdbc
of ms-access using java application i want to perform both operations of ms-access using jdbc connection   import java.sql.*; public class CreateTable... = DriverManager.getConnection("jdbc:odbc:student"); Class.forName
Mysql & java - JDBC
to connect to mysql 5.1 using java. But it shows error about: Class.forName...; String url = "jdbc:mysql://localhost:3306/"; String dbName... on JDBC visit to : http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml
JDBC
retrieve the value from database into dropdown list using JDBC SQL 2005  How to retrieve the value from database into dropdown list using JDBC &...").newInstance(); String connectionURL = "jdbc:mysql://localhost:3306/test";; Connection
jdbc
how i can access Microsoft Access database by java program  how i can access Microsoft Access database by java program ? if any package or jar file required then please specify it. please give java source code for such database
jdbc
define resulset?define stored procedure? exmp  define resulset?define stored procedure? exmp   ResultSet: ResultSet is a java object... logical group of data with a number of columns. JDBC ResultSet Example Stored
JDBC
JDBC  How to connect JAVA Servlet with the database
jdbc
jdbc  I compiling my jdbcodbc progrm. D:\Java\jdk1.6.0\bin>javac JdbcExample.java JdbcExample.java:12: cannot find symbol symbol : method...{ Connection con; con=DriverManager.getConnection("jdbc:odbc:student
about java swing - Java Beginners
about java swing   How to send date in data base if i use the combobox like as dd,mm,yyyy. plz reply thanx a lot  Hi Friend, Try...("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc
jdbc
jdbc  how can i store the image file and retrive the images from the database using java with querys also   import java.sql.*; import... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root
jdbc
question is all about and that also reduce the chances to get answer quickly. So
jdbc
jdbc  write a java program to accept the details of employee(eno,ename,sal)from the user and insert into the database(use awt
jdbc
jdbc  if i create one table that consist of usename ,joiningdate for joining date i have used varchar datatype not date . then we store date into database table as a string by using java .then what are the drawbacks
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc
jdbc  sir i want a java code which have some method(new a/c(),update a/c(),serchUser(through id ),getuser(id , pass),changePass(id, id)); using oracle 10g thank u
jdbc driver for mysql - Java Beginners
jdbc driver for mysql  I need jdbc driver program for connecting java... of jdbc-mysql database connectivity and idea about jdbc and mysql driver. http://www.roseindia.net/jdbc/ Thanks
JDBC - JDBC
Java technology-enabled driver converts JDBC calls into calls on the client API... middleware products.Type 4: JDBC Net pure Java DriverA native-protocol fully Java...explanation of JDBC drivers  Need tutorial on JDBC driversThanks
JDBC - JDBC
JDBC  i am goint to work on JDBC and i knew oracle but very poor in java is it possoble to me to do JDBC is it so please give me SOME SAMPLE ILLUSTRATIONS to understand the way to do work in JDBC with syntaxes  Hi
JDBC - JDBC
JDBC  how to do connectivity with SQL Server and MS Access in java... MSAccess in Java : import java.sql.*; public class... String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D
About Java
About Java  Hi, Can anyone tell me the About Java programming language? How a c programmer can learn Java development techniques? Thanks   Hi, Read about java at http://www.roseindia.net/java. Thanks
JDBC Tutorial, JDBC API Tutorials
Java Database Connectivity(JDBC) Tutorial This tutorial on JDBC explains you... to use JDBC API effectively to develop database driven applications in Java. You... to JDBC Java database connectivity or JDBC is an interface (API) used
Sitemap JDBC Tutorial Section
| APIs Become Available JDBC | Accessing Database using Java and JDBC... | JDBC connection timeout | JDBC Connectivity Code In Java | JDBC Drive...Home | About-us | Contact Us | Advertisement | Ask Questions | Site
jdbc - JDBC
."); Connection conn = null; String url = "jdbc:mysql://localhost:3306... on Netbeans and jdbc visit to : http://www.roseindia.net/jdbc/ http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.