nexux 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Code/__init__.py +0 -0
- Code/code.py +141 -0
- nexux-1.0.0.dist-info/METADATA +6 -0
- nexux-1.0.0.dist-info/RECORD +6 -0
- nexux-1.0.0.dist-info/WHEEL +5 -0
- nexux-1.0.0.dist-info/top_level.txt +1 -0
Code/__init__.py
ADDED
|
File without changes
|
Code/code.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# SERVLET HTML AND CODE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# import java.io.*;
|
|
5
|
+
# import java.sql.*;
|
|
6
|
+
# import javax.servlet.*;
|
|
7
|
+
# import javax.servlet.annotation.WebServlet;
|
|
8
|
+
# import javax.servlet.http.*;
|
|
9
|
+
|
|
10
|
+
# @WebServlet("/StudentServlet")
|
|
11
|
+
# public class StudentServlet extends HttpServlet {
|
|
12
|
+
# private static final String URL = "jdbc:mysql://localhost:3306/studentdb";
|
|
13
|
+
# private static final String USER = "root";
|
|
14
|
+
# private static final String PASS = "root";
|
|
15
|
+
|
|
16
|
+
# private Connection getConnection() throws Exception {
|
|
17
|
+
# Class.forName("com.mysql.cj.jdbc.Driver");
|
|
18
|
+
# return DriverManager.getConnection(URL, USER, PASS);
|
|
19
|
+
# }
|
|
20
|
+
|
|
21
|
+
# // READ (GET request)
|
|
22
|
+
# protected void doGet(HttpServletRequest req, HttpServletResponse res)
|
|
23
|
+
# throws ServletException, IOException {
|
|
24
|
+
# res.setContentType("text/html");
|
|
25
|
+
# PrintWriter out = res.getWriter();
|
|
26
|
+
|
|
27
|
+
# try (Connection con = getConnection();
|
|
28
|
+
# Statement st = con.createStatement();
|
|
29
|
+
# ResultSet rs = st.executeQuery("SELECT * FROM students")) {
|
|
30
|
+
|
|
31
|
+
# out.println("<h3>Student List</h3><table border='1'>");
|
|
32
|
+
# out.println("<tr><th>ID</th><th>Name</th><th>Course</th></tr>");
|
|
33
|
+
# while (rs.next()) {
|
|
34
|
+
# out.println("<tr><td>" + rs.getInt("id") + "</td><td>"
|
|
35
|
+
# + rs.getString("name") + "</td><td>"
|
|
36
|
+
# + rs.getString("course") + "</td></tr>");
|
|
37
|
+
# }
|
|
38
|
+
# out.println("</table><br><a href='index.html'>Back</a>");
|
|
39
|
+
# } catch (Exception e) {
|
|
40
|
+
# out.println("Error: " + e.getMessage());
|
|
41
|
+
# }
|
|
42
|
+
# }
|
|
43
|
+
|
|
44
|
+
# // CREATE, UPDATE, DELETE (POST request)
|
|
45
|
+
# protected void doPost(HttpServletRequest req, HttpServletResponse res)
|
|
46
|
+
# throws ServletException, IOException {
|
|
47
|
+
# res.setContentType("text/html");
|
|
48
|
+
# PrintWriter out = res.getWriter();
|
|
49
|
+
|
|
50
|
+
# String action = req.getParameter("action");
|
|
51
|
+
# int id = Integer.parseInt(req.getParameter("id"));
|
|
52
|
+
# String name = req.getParameter("name");
|
|
53
|
+
# String course = req.getParameter("course");
|
|
54
|
+
|
|
55
|
+
# try (Connection con = getConnection()) {
|
|
56
|
+
# PreparedStatement ps;
|
|
57
|
+
# if ("create".equals(action)) {
|
|
58
|
+
# ps = con.prepareStatement("INSERT INTO students VALUES (?, ?, ?)");
|
|
59
|
+
# ps.setInt(1, id);
|
|
60
|
+
# ps.setString(2, name);
|
|
61
|
+
# ps.setString(3, course);
|
|
62
|
+
# ps.executeUpdate();
|
|
63
|
+
# out.println("Record Inserted!<br>");
|
|
64
|
+
# } else if ("update".equals(action)) {
|
|
65
|
+
# ps = con.prepareStatement("UPDATE students SET name=?, course=? WHERE id=?");
|
|
66
|
+
# ps.setString(1, name);
|
|
67
|
+
# ps.setString(2, course);
|
|
68
|
+
# ps.setInt(3, id);
|
|
69
|
+
# ps.executeUpdate();
|
|
70
|
+
# out.println("Record Updated!<br>");
|
|
71
|
+
# } else if ("delete".equals(action)) {
|
|
72
|
+
# ps = con.prepareStatement("DELETE FROM students WHERE id=?");
|
|
73
|
+
# ps.setInt(1, id);
|
|
74
|
+
# ps.executeUpdate();
|
|
75
|
+
# out.println("Record Deleted!<br>");
|
|
76
|
+
# }
|
|
77
|
+
# out.println("<a href='index.html'>Back</a> | <a href='StudentServlet'>View All</a>");
|
|
78
|
+
# } catch (Exception e) {
|
|
79
|
+
# out.println("Error: " + e.getMessage());
|
|
80
|
+
# }
|
|
81
|
+
# }
|
|
82
|
+
# }
|
|
83
|
+
|
|
84
|
+
# <!DOCTYPE html>
|
|
85
|
+
# <html>
|
|
86
|
+
# <head><title>Student CRUD</title></head>
|
|
87
|
+
# <body>
|
|
88
|
+
# <h2>Student CRUD Operations</h2>
|
|
89
|
+
# <form action="StudentServlet" method="post">
|
|
90
|
+
# ID: <input type="number" name="id" required><br><br>
|
|
91
|
+
# Name: <input type="text" name="name"><br><br>
|
|
92
|
+
# Course: <input type="text" name="course"><br><br>
|
|
93
|
+
|
|
94
|
+
# <button type="submit" name="action" value="create">Insert</button>
|
|
95
|
+
# <button type="submit" name="action" value="update">Update</button>
|
|
96
|
+
# <button type="submit" name="action" value="delete">Delete</button>
|
|
97
|
+
# </form>
|
|
98
|
+
# <br>
|
|
99
|
+
# <a href="StudentServlet">View All Students (Read)</a>
|
|
100
|
+
# </body>
|
|
101
|
+
# </html>
|
|
102
|
+
|
|
103
|
+
# JDBC DATABASE CODE
|
|
104
|
+
|
|
105
|
+
# import java.sql.Connection;
|
|
106
|
+
# import java.sql.DriverManager;
|
|
107
|
+
# import java.sql.Statement;
|
|
108
|
+
|
|
109
|
+
# public class CreateDbAndTable {
|
|
110
|
+
# public static void main(String[] args) {
|
|
111
|
+
|
|
112
|
+
# String url = "jdbc:mysql://localhost:3306/";
|
|
113
|
+
# String user = "root";
|
|
114
|
+
# String password = "root";
|
|
115
|
+
|
|
116
|
+
# try {
|
|
117
|
+
# Class.forName("com.mysql.cj.jdbc.Driver");
|
|
118
|
+
|
|
119
|
+
# try (Connection con = DriverManager.getConnection(url, user, password);
|
|
120
|
+
# Statement st = con.createStatement()) {
|
|
121
|
+
|
|
122
|
+
# st.executeUpdate("CREATE DATABASE IF NOT EXISTS college_db");
|
|
123
|
+
# System.out.println("Database created.");
|
|
124
|
+
|
|
125
|
+
# st.executeUpdate("USE college_db");
|
|
126
|
+
|
|
127
|
+
# String sql = "CREATE TABLE IF NOT EXISTS students ("
|
|
128
|
+
# + "id INT PRIMARY KEY AUTO_INCREMENT, "
|
|
129
|
+
# + "name VARCHAR(50) NOT NULL, "
|
|
130
|
+
# + "marks INT)";
|
|
131
|
+
|
|
132
|
+
# st.executeUpdate(sql);
|
|
133
|
+
|
|
134
|
+
# System.out.println("Students table created.");
|
|
135
|
+
# }
|
|
136
|
+
|
|
137
|
+
# } catch (Exception e) {
|
|
138
|
+
# e.printStackTrace();
|
|
139
|
+
# }
|
|
140
|
+
# }
|
|
141
|
+
# }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Code/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
Code/code.py,sha256=4Jj5Umc0beB04rBhg5JFbD_4yGGJCBb3HD62Sj16wxM,5418
|
|
3
|
+
nexux-1.0.0.dist-info/METADATA,sha256=A3bZCImmoq0D-NgzC-Auovci338Se2yuw1d99wXRrMo,132
|
|
4
|
+
nexux-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
nexux-1.0.0.dist-info/top_level.txt,sha256=5dSMF0KOskVmT0QGz9KnqcD9Ccc2Dkq0Sa8FOZk-7Ck,5
|
|
6
|
+
nexux-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Code
|