subrat_p 0 Newbie Poster

I have a textfield, and that only accept integer numbers. If user input charter type value it shows JOptionpane Error Message and when user click on the ok button in optionpane message the textfield clear itself

public void nosgetit(DocumentEvent documentEvent){
        DocumentEvent.EventType type = documentEvent.getType();
        if(type.equals(DocumentEvent.EventType.CHANGE)){

        }
        if(type.equals(DocumentEvent.EventType.INSERT)){

                String ns=nos_txt.getText();
                char [] c=ns.toCharArray();
                for(int i=0; i < ns.length(); i++){
                   if ( !Character.isDigit(c[i])){
                       JOptionPane.showMessageDialog(null, "You must input number", "ERROR",
                                      JOptionPane.ERROR_MESSAGE);

                   } 
                }
        }
        if(type.equals(DocumentEvent.EventType.REMOVE)){

        }
    }
subrat_p 0 Newbie Poster

Hello friends,

I have created three JComboBoxes. first two of them get list from string. However I select these two comboboxes, the third combobox automatically retrieve data of a particular column from my database. But in my code its only get data from first item which automatically seleted by setmodel method. Here I paste the code . Please suggest where I stucked!

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frame1.java
 *
 * Created on Oct 25, 2012, 2:00:29 PM
 */
package smit.cse;
import java.sql.*;
/**
 *
 * @author MYPC
 */
public class frame1 extends javax.swing.JFrame {

    /** Creates new form frame1 */
    public frame1() {
        initComponents();
        String str=(String)jComboBox1.getSelectedItem();

        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn = DriverManager.getConnection("jdbc:odbc:feeds");
            Statement st=conn.createStatement();
            ResultSet rs=st.executeQuery("Select * from staffs where dept_name like'"+str+"'");
            while(rs.next()){
                String str1=rs.getString("subject");
                System.out.println(str);
                jComboBox2.addItem(str1);
            }
        }
            catch(Exception e){}


        }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "EEE", "ETC", "CSE" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(95, 95, 95)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(125, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, …
subrat_p 0 Newbie Poster

what is print api. Can I use any reporting tools for that. And if it is possible please help me because I don't know how to use reporting tools in java

subrat_p 0 Newbie Poster

I want to do a project on hotel management. But I can not know how to take the print of the bill of a customer. After I entered data in textfield how to take printout those data in a money receipt format.

subrat_p 0 Newbie Poster

I installed Oracle9i on my PC which run Win XP. But I can not open "isqlplus" in my web browser. I have some more machines which connect to the server through LAN. And I want to run oracle isqlplus on those system by the IP address of server machine. I tried but I can not open it by IP address. One of my friend told me to install IIS by which it can possible. But nothing happend after that also. So please help me on this.

subrat_p 0 Newbie Poster
import java.awt.event.*;
import javax.swing.*;


public class input extends JApplet {
    private JLabel lab1;
    private JButton btn1;


    public void init() {
        // TODO start asynchronous download of heavy resources
        lab1 = new JLabel();
        btn1 = new JButton();

        lab1.setText("Press the Button");
        btn1.setText("ENTER");

        this.add(lab1);
        this.add(btn1);

        //transfer tran=new transfer();
        btn1.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(82, 82, 82)
                        .addComponent(lab1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(133, 133, 133)
                        .addComponent(btn1)))
                .addContainerGap(202, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(73, 73, 73)
                .addComponent(lab1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(btn1)
                .addContainerGap(141, Short.MAX_VALUE))
        );


    }


    private void btn1ActionPerformed(ActionEvent evt) {                                         
        // TODO add your handling code here:
        //Object obj = evt.getSource();
        show shw=new show();
        shw.setVisible(true);
        System.out.println("HELLO");
        //this.setVisible(false);

    } 

 }



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

    public class show extends JPanel {

        private JFrame converterFrame;
        String s1,s2,s3;

        private int checkInput(String inString) {

            StringBuffer tStringBuf;
            int flag=0; 
            tStringBuf=new StringBuffer(inString);
            //check each input character to see if it is a number
            for(int index=0; index<tStringBuf.length(); index++){
                char ch=tStringBuf.charAt(index);
                if( (ch<'0' || ch>'9') && (ch !='.')){
                    flag=1;
                    break;
                }
            }
            if(flag==1) return 0;
            //not a number input
            else return 1;  //input is right

        }

        private void doubleit(){
            if( (txt_fld.getText().length()!=0 && checkInput(txt_fld.getText()) ==0))
                {
                    JOptionPane.showMessageDialog(converterFrame,
                    "input is not a number", "Warning",
                    JOptionPane.WARNING_MESSAGE);
                return;
            }

        }

        /** Creates new form show */
        public show() {
            initComponents();
        }


        @SuppressWarnings("unchecked")

        private void initComponents() {

            jLabel1 = new javax.swing.JLabel();
            dou_btn = new javax.swing.JButton();
            txt_fld = new javax.swing.JTextField();

            setBackground(new java.awt.Color(204, 204, 0));

            jLabel1.setText("Double the Value");

            dou_btn.setBackground(new …
subrat_p 0 Newbie Poster

through the applet program can i call a JFrame class? is it possible

subrat_p 0 Newbie Poster

When "ENTER" button in value class clicked the show class wil be run. but nothing happend

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


/*<applet code ="value" width=200 height=200>
</applet>*/

public class value extends Applet {

     private JLabel lab1;
    private JButton btn1;

      public void init () {

        // Construct the TextFields
     this.lab1 = new JLabel("Press the button");
     this.btn1 = new JButton("ENTER");

     // add the button to the layout
     this.add(lab1);
     this.add(btn1);

     transfer tran=new transfer();
     btn1.addActionListener(tran);

      }

      private class transfer implements ActionListener
        {
            public void actionPerformed(ActionEvent e)
                {
                    show sh = new show();
                    sh.setVisible(true);
                }

        }


}




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




public class show extends Applet {

     private JLabel lab2;
     private JButton btn2;
     private JTextField txt2;
     String s1,s2;

      public void init () {

     // Construct the TextFields
     this.lab2 = new JLabel("Enter a number");
     this.btn2 = new JButton("DOUBLE");
     this.txt2 = new JTextField(20);
     this.txt2.setEditable(true);

     // add the button to the layout
     this.add(lab2);
     this.add(txt2);
      this.add(btn2);

      summation sa = new summation(txt2);
     btn2.addActionListener(sa);
     this.txt2.addActionListener(sa);

     }
      private int checkInput(String inString) {

        StringBuffer tStringBuf;
        int flag=0; 
        tStringBuf=new StringBuffer(inString);
        //check each input character to see if it is a number
        for(int index=0; index<tStringBuf.length(); index++){
            char ch=tStringBuf.charAt(index);
            if( (ch<'0' || ch>'9') && (ch !='.')){
                flag=1;
                break;
            }
        }
        if(flag==1) return 0;
        //not a number input
        else return 1;  //input is right

    }

    class summation implements ActionListener {
         private JTextField txt3;

         public summation(JTextField txt3)
         {
            this.txt3=txt3;

         }

         public void actionPerformed(ActionEvent ae) {
            if(ae.getSource()==btn2)
        {
            s1=txt3.getText();
            int i = Integer.parseInt(s1);
            int result=i*2;
            s2 = new Integer(result).toString();
            txt3.setText(s2);

        } …
subrat_p 0 Newbie Poster

Hello frnds,
Please help me on this java program

"Implement Generic programming to perform arithmetic evaluation using command line argument."

subrat_p 0 Newbie Poster
public class examination extends javax.swing.JFrame {
    public Connection con;
    public Statement stmt;
    public ResultSet rs;
    public String sname,sid,sub;

    /** Creates new form examination */
    public examination() {
        welcome wl=new welcome();
        String stname=wl.regdno.getSelectedText();
        
        try
                {
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    con=DriverManager.getConnection("jdbc:odbc:exam");
                    Statement stmt=con.createStatement();
                    ResultSet rs=stmt.executeQuery("SELECT * FROM student where sno='"+stname+"'");
                    while(rs.next())
                    {
                    sid=rs.getString(1);
                    sname=rs.getString(2);
                    }

                }
                catch(ClassNotFoundException e)  {
 			System.err.println("Failed to load driver");
 			e.printStackTrace();
                }catch(SQLException e){
 			System.err.println("Unable to connect");
 			e.printStackTrace();}
                initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        stname = new javax.swing.JLabel("Student Name:"+sname);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(stname, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(174, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(stname, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(271, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void ex() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new examination().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel stname;
    // End of variables declaration//GEN-END:variables

}

Where welcome is another class where I have a text field named "regdno". Now I want to get the data what I put into the textfield to …

subrat_p 0 Newbie Poster

Hello friends,
I have a problem about JLabel

I want to insert a data from database into my JLebel.setText() method.Please help me

subrat_p 0 Newbie Poster

please help me ...its urgent...i'm in between middle of the project

subrat_p 0 Newbie Poster
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;

public class civil_fst extends JFrame implements ItemListener, ActionListener{

    static Connection con;
    static Statement stmt;
    static ResultSet rs;
    static ResultSetMetaData rsMeta;

    String query;
    String ref="",rollno="";
    String[] heads;
    int[] stChange;
    String[][] cubeData;
    int rows, cols, coo;

    /** Creates new form civil_fst */
    public civil_fst() {
        initComponents();

        con  = null;
        stmt = null;
        rs = null;
        rsMeta=null;

        query="SELECT *  FROM  civilfattnd order by Regd_No";
        rows=0;
        cols=0;
        coo=0;

        try
            {
                Class.forName("com.mysql.jdbc.Driver");
                con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
                con.setAutoCommit(true);
                stmt=con.createStatement();

                rs=stmt.executeQuery(query); //execute the query and get resultset(rs)
                rsMeta=rs.getMetaData(); //get rs metadata
                cols=rsMeta.getColumnCount(); // get number of columns
                coo=cols-1;

                while(rs.next()) { 				// get rows in resultset
			      ++rows;
			   }
                heads = new String[cols];			// initialize col heads

                for (int i = 0; i < cols; i++) {  		// getting colums  heading in heads[]
                    int colindex=i+1;				// column indexes start from 1
                    heads[i] = rsMeta.getColumnName(colindex);
                }
                stChange = new int[rows];			//to save value when status changed


                rs=stmt.executeQuery(query);		// execure query and get resultset (rs)
                cubeData = new String[rows][cols];			// initialize table data

                int j=0; int k=0;				// function to get resultset data
                while(rs.next())
                {
                    if(j<=rows)
                    {
                        int h=1;
                        if(k<=cols)
                        {
                            for(int cc=0;cc<cols; cc++)
                            {
                                cubeData[j][k]=rs.getString(h);
                                h++;
                                k++;
                            }
                        }
                        k=0;h=0;
                        j++;
                    }
                }
        }
        catch(Exception ex)
		 { System.err.println(ex.getMessage());
		   ex.printStackTrace(System.err);
		 }

        cp.setLayout(new GridLayout(rows+2,cols)); // 1 additional Row of Col heading, 1 for save btn


        //---------------- Adding heading in CP---------------------------------------

	for (int i = 0; i < cols; i++) {
		JLabel jl = new JLabel(" [ "+heads[i]+" ] ");
		jl.setOpaque(true);
		jl.setBackground(Color.gray);
		jl.setForeground(Color.white);
		cp.add(jl);

	}

	//---------------- Adding …
subrat_p 0 Newbie Poster
public void actionPerformed(ActionEvent ae) {

	try{
		String create="CREATE TABLE civ_fourth (`Name` VARCHAR(50), `Regd_No` INT, `Status` VARCHAR(20) NOT NULL)";
                con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
                stmt.executeUpdate(create);
                con.close();
            }
            catch(Exception ex)
             { System.err.println(ex.getMessage());
             ex.printStackTrace(System.err);
             }

             try{
                for(int j=0; j<rows; j++)
		{
			String ins="INSERT INTO civ_fourth (`Regd_No`,`Status`) VALUES('"+stChange[j]+","+cubeData[j][coo]+")";

			con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");


                        PreparedStatement ps=con.prepareStatement(ins);
		}
			//this.con.commit();
                        con.setAutoCommit(true);
			System.out.println("Records updated..!");
			con.close();

	}catch(Exception ex)
	 { System.err.println(ex.getMessage());
	   ex.printStackTrace(System.err);
	 }
  }

But its create the table but inserting data is not possible.

subrat_p 0 Newbie Poster
public void actionPerformed(ActionEvent ae) {

	try{
		String create="CREATE TABLE civ_fourth (`Name` VARCHAR(50), `Regd_No` INT, `Status` VARCHAR(20) NOT NULL)";
                con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");
                stmt.executeUpdate(create);
                con.close();
            }
            catch(Exception ex)
             { System.err.println(ex.getMessage());
             ex.printStackTrace(System.err);
             }

             try{
                for(int j=0; j<rows; j++)
		{
			String ins="INSERT INTO civ_fourth (`Regd_No`,`Status`) VALUES('"+stChange[j]+","+cubeData[j][coo]+")";

			con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","root");


                        PreparedStatement ps=con.prepareStatement(ins);
		}
			//this.con.commit();
                        con.setAutoCommit(true);
			System.out.println("Records updated..!");
			con.close();

	}catch(Exception ex)
	 { System.err.println(ex.getMessage());
	   ex.printStackTrace(System.err);
	 }
  }

But its create the table but inserting data is not possible.

subrat_p 0 Newbie Poster

i can not solve this please help me I have 3 fields to fill by insert for Name, Regd_no & status but I have only 2 objects cubeData[j][coo] & stChange[j] for status and regd_no but how can i get all names from the frame and insert into the new table?

subrat_p 0 Newbie Poster

So then use an insert and not an update. Jeez. Learn SQL. And do not cobble together statements like that unless want an SQL Injection attack or spurious invalid SQL errors.

try{
for(int j=0; j<rows; j++)
{
String ins="INSERT INTO <tablename>(`col1`, `col2`, `con3`) VALUES ('xyz', 123456, 'abc');"

but see in the update statement there is some object passes cubeData[j][coo] & stChange[j] to the query which are derived from the existing frame where only status column is updated where Rollno is find. But how can i insert these into new table?

String updt = "update students set Status= '"+cubeData[j][coo]+"' where Rollno="+stChange[j];
this.con=DriverManager.getConnection(this.dbURL);
this.stmt.executeUpdate(updt);
}
this.con.commit();
System.out.println("Records updated..!");
con.close();
}catch(Exception ex)
{ System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
}
}
subrat_p 0 Newbie Poster

You should write DSN name in the Driver connection methods so you will get some idea about the errors.

this.con=DriverManager.getConnection("jdbc:mysql://localhost:3307/<databasename>","root","root");

I used MySQL so its not required any DSN name.

subrat_p 0 Newbie Poster

I know about create new table in database through java. But I can't insert the data into this created table. Because there is some parameter passed into the table
//---------------------Action Listener-----------------------------------------

public void actionPerformed(ActionEvent ae) {

try
{
String create="CREATE TABLE <table name> (`Name` VARCHAR(50), `Regd_No` INT, `Status` VARCHAR(20) NOT NULL)";
this.con=DriverManager.getConnection(this.dbURL);
this.stmt.executeUpdate(updt);
}
{ System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
}

through this code when i clicked the save button it create a new table but I don't know how to insert data into this new table. Because in the below code I update a existing column through passing some objects i.e.cubeData[j][coo] & stChange[j]. But I want to create a new table in the name of current date and insert data through these objects cubeData[j][coo] & stChange[j]

try{
for(int j=0; j<rows; j++)
{
String updt = "update students set Status= '"+[B]cubeData[j][coo][/B]+"' where Rollno="+[B]stChange[j][/B];
this.con=DriverManager.getConnection(this.dbURL);
this.stmt.executeUpdate(updt);
}
this.con.commit();
System.out.println("Records updated..!");
con.close();

}catch(Exception ex)
{ System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
}
}
subrat_p 0 Newbie Poster
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.util.*;

public class attendance extends JFrame implements ItemListener, ActionListener
{
static Connection con;
static Statement stmt;
static ResultSet rs;
static ResultSetMetaData rsMeta;
String query;


   	 String ref="",rollno="";
   	String[] heads;
int[] stChange;
    	String[][] cubeData;
int rows, cols, coo;
	
	public attendance(String tit, String qry){
		this.con  = null;
		this.stmt = null;
		this.rs = null;
		this.rsMeta=null;	

		this.query=qry;
		this.title=tit;
		this.rows=0;
		this.cols=0;
		this.coo=0;

		cp = getContentPane();

		try
		{ 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");		this.con=DriverManager.getConnection("jdbc:mysql://localhost:3307/<databasename>","root","root");	
			this.con.setAutoCommit(true);
			this.stmt=this.con.createStatement();

			this.rs=this.stmt.executeQuery(query);		// execure query and get resultset (rs)
			rsMeta = rs.getMetaData();			// get rs metadata
			this.cols = rsMeta.getColumnCount();		// get number of colums
			this.coo =this.cols-1;
			while(rs.next()) { 				// get rows in resultset
			      ++this.rows; 
			   }

			heads = new String[cols];			// initialize col heads
			
			for (int i = 0; i < cols; i++) {  		// getting colums  heading in heads[]
     				int colindex=i+1;				// column indexes start from 1
				heads[i] = rsMeta.getColumnName(colindex);
				}



			stChange = new int[rows];			//to save value when status changed


			this.rs=this.stmt.executeQuery(query);		// execure query and get resultset (rs)
			cubeData = new String[rows][cols];			// initialize table data
	
			int j=0; int k=0;				// function to get resultset data
			while(rs.next())
			{
				if(j<=rows)
				{	int h=1;
					if(k<=cols)
					{
						for(int cc=0; cc<cols; cc++)
						{	cubeData[j][k]=rs.getString(h);
							h++; 
							k++;
						}
					}
					k=0;h=0;
					j++;
				}
			}


		
		}catch(Exception ex)
		 { System.err.println(ex.getMessage());
		   ex.printStackTrace(System.err);
		 }

	
	cp.setLayout(new GridLayout(rows+2,cols)); // 1 additional Row of Col heading, 1 for save btn

	//---------------- Adding heading in CP---------------------------------------

	for (int i = 0; i < cols; i++) {
		JLabel jl = new JLabel(" [ "+heads[i]+" ] ");
		jl.setOpaque(true);
		jl.setBackground(Color.gray);
		jl.setForeground(Color.white);
		cp.add(jl); …
subrat_p 0 Newbie Poster
try
                {
                Class.forName("com.mysql.jdbc.Driver");
                con=DriverManager.getConnection("jdbc:mysql://localhost:3307/dbname","root","root");
                }
                catch(ClassNotFoundException e)  {
            System.err.println("Failed to load driver");
            e.printStackTrace();
        }catch(SQLException e){
            System.err.println("Unable to connect");
            e.printStackTrace();}

private void s_comboItemStateChanged(java.awt.event.ItemEvent evt) {
        // TODO add your handling code here:
        if(evt.getSource()==f_combo)
        {
            try
            {
                Statement st=con.createStatement();
                ResultSet rs=st.executeQuery("SELECT * FROM tablename WHERE column = '" +f_combo.getSelectedItem()+"'");

                while(rs.next())
                {
                    s_combo.addItem(rs.getInt("3"));
                }
            }
            catch(SQLException sq)
            {
                sq.printStackTrace();
            }
        }
    }

f_combo contains branches and s_combo link to my database table which contains all subjects. When I select a particular branch from f_combo then all subjects of that branch add in the s_combo. But my code does not retrieve the data from my table to s_combo. Please help me on this

subrat_p 0 Newbie Poster

please any one help me ....its necessary and urgent

subrat_p 0 Newbie Poster

I am a learner in java . I want to connect my MYSQL database table to a combo box. I created 3 combo box on my jpanel.When I select first two combo box items its automatically call the data base and show the particular content from my table in the last combo box.

Like when we choose the country combo box in a web page its automatically listed all the states belong to the particular country.

So pleas send some example code for my problem

subrat_p 0 Newbie Poster

I have Dell Inspiron Laptop with Intel Core i3 and preloaded Windows 7 64bit. But few days ago I faced virus problem with my laptop so I formatted my system. I have already 3 dvds of backup file and one is restore windows 7 64bit bootable dvd. But I could not restore from my backup dvds

subrat_p 0 Newbie Poster

I want to see all Name from my excel sheet who are belong same City. So can please tell me any excel formula for this

Awaiting

subrat_p 0 Newbie Poster

I am newbie to MySQL.I create a database in MySQL in command shell by "create database DBNAME". But I can not use my own created database.So friends help me how to log into my database named "DBNAME" because I want to create some tables in that.

Thank You

subrat_p 0 Newbie Poster

When I execute the jar file in cmd as you said like:
java -jar MyJar.jar

Failed to load Main-Class manifest attribute from
MyJar.jar

And when I simply double clicked on the particular jar file its give a error sound and nothing happened.I already set the java path and jre path in the "environmental variables" section.

Through Netbeans I create the jar file

subrat_p 0 Newbie Poster

I tried a lot to open a JAR file but it is not opening.I typed in command prompt

javaw -jar MyJar.jar but it is not open. It makes some error sound bt not open.

Please help me regard this