Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions Chat/Server.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package javaapplication10;

import java.net.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.sql.*;


public class Server
Expand Down Expand Up @@ -145,8 +138,8 @@ public void check(String username, String password)
// Step 3: Create a table (you can skip this step if the table already exists)

// Step 4: Insert data into the table
/*String insertQuery = "INSERT INTO users VALUES ('John', 'xountas') , ('Jim','kont')";
stmt.executeUpdate(insertQuery);*/
String insertQuery = "INSERT INTO users VALUES ('John', 'xountas') , ('Jim','kont')";
stmt.executeUpdate(insertQuery);

// Step 5: Retrieve data from the table
String selectQuery = "SELECT * FROM users";
Expand All @@ -158,12 +151,9 @@ public void check(String username, String password)
String username1 = rs.getString("username");
String pass = rs.getString("password");
System.out.println("Name: " + username1 + ", Age: " + pass);
System.out.println("Name: " + this.clientUsername + ", pass: " + this.clientPassword);
if(this.clientUsername.equals(username1) && this.clientPassword.equals(pass))
{
System.out.println("1");
connected = "true";
break;
}
}

Expand All @@ -174,10 +164,9 @@ public void check(String username, String password)
} catch (Exception e) {
e.printStackTrace();
}

try
{
System.out.println("1" + connected);
bufferedWriter.write(connected);
bufferedWriter.newLine();
bufferedWriter.flush();
Expand Down