Thursday, December 8, 2011

Sunday, December 4, 2011

grant access to an ip of my DB

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'

sql random row generate

The simplest way of selecting random rows from the MySQL database is to use "ORDER BY RAND()" clause in the query. Solution 1 [SQL] SELECT * FROM `table` ORDER BY RAND() LIMIT 0,1;

Saturday, August 20, 2011

jtable remove row

((DefaultTableModel)jTable1.getModel()).removeRow(3);

jtable add row

((DefaultTableModel)jTable1.getModel()).addRow(new Object [] {null, null, null, null,null,null,null});

put value on j table

jTable1.getModel().setValueAt(((String) jComboBox1.getItemAt(jComboBox1.getSelectedIndex())), 0, 0);

Friday, July 22, 2011

vector (some function of vector)

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

import java.util.Scanner;
import java.util.Vector;

/**
*
* @author LLynAs
*/
public class VectorTest {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Vector v=new Vector();
v.addElement("hello");
v.add("hi");
v.add("bye");

System.out.println(v);

for(Object element: v){

System.out.println(element);

}

System.out.println(v.elementAt(0));
System.out.println(v.capacity());

Scanner ip=new Scanner(System.in);
// System.out.println("Enter here::");
// for(int i=0;i<5;i++){
// v.add(ip.next());
// }
// for(Object element: v){
//
// System.out.println(element);
//
// }
v.removeElement("helo");
v.removeElementAt(0);



System.out.println(v.indexOf("hi",1));
}
}

Vector element equal test

for(Object element: userid){
if("user1".equals((String) element)){
System.out.println("ok");

}
}

Thursday, May 19, 2011

add row in jtable

((DefaultTableModel)jTable1.getModel()).addRow(busyIcons);

((DefaultTableModel)jTable1.getModel()).addRow(new Object [] {null, null, null, null});

add value to a specific position of a table

jTable1.getModel().setValueAt(jTextField1.getText(), 0, 3);

for each element of the array

for ( char character : charArray )
System.out.print( character );


//here char array is the array and character is each element of chararray

Convert int to string

int aInt = 1;

String aString = Integer.toString(aInt);