public class LOGINToRegistration extends [Link].
JFrame {
final static String JDBC_DRIVER = "[Link]";
final static String DB_URL = "jdbc:mysql://localhost:3306/thirdyear";
final static String USER_NAME = "root";
final static String PASSWORD = "";
public LOGINToRegistration() {
initComponents();
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void LOGINToRegistrationActionPerformed([Link] evt) {
if([Link]().length()== 0 && [Link]().length == 0 ){ // Checking for
empty field
[Link]("Empty fields detected ! Please fill up both");}
else if( [Link]().length()== 0 ) // Checking for empty field
[Link]("Empty fields detected ! Please fill up username");
else if( [Link]().length == 0 ) // Checking for empty field
[Link]("Empty fields detected ! Please fill up password");
else
{ String u = [Link](); // Collecting the input
String p = [Link]();
try{
[Link](JDBC_DRIVER);
Connection con = [Link](DB_URL ,USER_NAME,PASSWORD);
Statement stmt = [Link]();
String logqry = "select * from login";
ResultSet rs = [Link](logqry);
while([Link]())
{ if( [Link]([Link]("Username"))&& [Link]([Link]("Password")))
[Link]();
new field().setVisible(true);
else{
[Link]("Wrong Username");
}catch (SQLException ex)
{ [Link](DBTest_JFrame.[Link]()).log([Link], null, ex); } catch
(ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null, ex);
[Link]("");
[Link]("");
}
public static void main(String args[]) {
[Link](new Runnable() {
public void run() {
new LOGINToRegistration().setVisible(true);
});
private void RegisterActionPerformed([Link] evt) {
try {
[Link](JDBC_DRIVER); // load driver
con = [Link](DB_URL, USER_NAME, PASSWORD);
insqry = "insert into student values(?,?,?,?)";
pstmt = [Link](insqry );
[Link]( 1 , [Link]() );
[Link]( 2, [Link]() );
[Link]( 3, [Link](0|1) );
[Link]( 4, [Link]() );
[Link]();
[Link](" 1 record is inserted" );
[Link](); [Link]();
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null, ex);
[Link]();
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null, ex);
private void ViewActionPerformed([Link] evt) {
try{
[Link](JDBC_DRIVER); // load driver
con = [Link](DB_URL, USER_NAME, PASSWORD);
stmt = [Link]();
selqry = "SELECT * FROM student";
rst = [Link](selqry);
while([Link]() )
{ [Link]("\nSTUDID\tFName\tSex\tAge"+"\n\n"
+[Link](1) + "\t" + [Link](2) +
"\t" + [Link](3) + "\t" + [Link](4));
[Link](); [Link](); [Link]();
}catch(Exception ex){
[Link]();
}
///////////////////////////////////////////////////////////////////////////////////////
import [Link].*;
import [Link].*;
public class chatserver
public static void main(String [] args)throws IOException
ServerSocket sockserv = new ServerSocket(1025 );
[Link]("Server is ready to chat....");
Socket cl = [Link]();
OutputStream out = [Link]();
PrintWriter pw = new PrintWriter(out,true);
BufferedReader br1 = new BufferedReader(new InputStreamReader([Link]));
InputStream in = [Link]();
BufferedReader br2 = new BufferedReader(new InputStreamReader(in));
String rxc, syc;
while(true)
{ if((rxc = [Link]()) != null)
[Link]("recieve from client: "+rxc);
syc = [Link]();
[Link](syc);
[Link]("sending to client: ");
}
//////////////////////////////////////////////////////////////////////////////////////
import [Link].*;
import [Link].*;
public class chatclient
public static void main(String [] args)throws IOException
Socket cl = new Socket("localhost",1025);
OutputStream out = [Link]();
PrintWriter pw = new PrintWriter(out,true);
BufferedReader br1 = new BufferedReader(new InputStreamReader([Link]));
InputStream in = [Link]();
BufferedReader br2 = new BufferedReader(new InputStreamReader(in));
[Link]("start chatting");
String rxc, syc;
while(true)
syc = [Link]();
[Link](syc);
[Link]("sending to server: ");
if((rxc = [Link]()) != null)
[Link]("recieve from server: "+rxc);
////////////////////////////////////////////////////////////////////////////////////////////
package chaptertwo;
import [Link].*;
import [Link];
public class FileCreateAndWriteAndRead // MyFileWriter
{ public static void main(String[] args) throws IOException
{ FileOutputStream fout = new FileOutputStream("C:\\Users\\user pc\\Desktop\\[Link]");
Scanner scan = new Scanner([Link]);
[Link]("Please, Enter your String: ");
String str = [Link]();
//String str = "this is file writing Example";
byte xx[] = [Link]();
for (int i = 0; i < [Link]; i++)
[Link](xx[i]);
}
[Link]();
[Link]("File created");
/* To Read created file */
FileInputStream fr = new FileInputStream("[Link]" );
byte b[] = new byte[[Link]()]; /*size of data with [Link] method */
[Link](b); //reading the data from Input Stream
String ss = new String(b); //The byte type array is converted into String
[Link]("The created is: " + ss); //Then String is printed on screen
[Link]();