SR
SR
try{
Thread.sleep(150),
} catch (InterruptedException e) {
e.printStackTrace();
t1.start();
t1.join();
import java.awt.*
import java.awt.event.*
Awt Example◊ {
// create a button
add(b);
dispose◊);
});
void display() {
import java.sql.Connection,
import java.sql.DriverManager,
import java.sql.Statement;
public class JdbcExample {
try{
String url="jdbcmysql://localhost:3306/yourDatabase",
String user="username",
String password="password";
// Establish Connection
// Create a statement
// Execute a query
while (rs.next()) {
Systemout.println(rs.getString("columnName"));
// Clean up environment
rsclose◊);
stmt.close();
conn.close();
} catch (Exception e) {
e printStackTrace();
<html>
<body>
<body> </html>
This HTML file would then be opened in a browser that supports Java applets or used with an applet
viewer tool provided with the JDK.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
while (resultSet.next()) {
System.out.println(resultSet.getString("name"));
resultSet.close();
statement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
this.message = msg;
System.out.println(message);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
System.out.println("Thread interrupted.");
thread1.start();
thread2.start();
import java.applet.Applet;
import java.awt.Graphics;
System.out.println("Applet initialized");
System.out.println("Applet starting");
System.out.println("Applet stopping");
System.out.println("Applet destroyed");
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
response.setContentType("text/html");
out.println("<html><body>");
out.println("<h1>Hello Servlet</h1>");
out.println("</body></html>");
This servlet would need to be deployed on a servlet container such as Apache Tomcat. You would also
need to configure it in the web.xml file or use annotations in newer Java versions to specify URL
patterns.