Skip to content

Commit

Permalink
o
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-gott committed Mar 19, 2021
1 parent c409001 commit e6a91f6
Show file tree
Hide file tree
Showing 38 changed files with 887 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DataBaseAccess1/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions DataBaseAccess1/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions DataBaseAccess1/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions DataBaseAccess1/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions DataBaseAccess1/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions DataBaseAccess1/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions DataBaseAccess1/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions DataBaseAccess1/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions DataBaseAccess1/DatabaseAccess1.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
46 changes: 46 additions & 0 deletions DataBaseAccess1/src/main/java/ExampleInsert/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ExampleInsert;

import java.sql.*;

public class Main {
public static void main(String[] args) throws SQLException {
Connection myConn = null;
Statement myStm = null;
ResultSet myRs = null;

String dbURL = "";
String user = "root";
String pass = "root";

try {
myConn = DriverManager.getConnection(dbURL, user, pass);

myStm = myConn.createStatement();

System.out.println("Inserting new employee");

int rowsAffected = myStm.executeUpdate(
"insert into x " +
"(last_name, first_name, email, department, salary) " +
"values " +
"('Example', 'firstName', 'Example@email.com', 'ExampleJob', '100000')");
myRs = myStm.executeQuery("select * from example order by firstName");

while(myRs.next()) {
System.out.println(myRs.getString("Example") + ", " + myRs.getString("firstName"));
}
} catch (Exception err) {
err.printStackTrace();
} finally {
if(myRs != null) {
myRs.close();
}
if(myStm != null) {
myRs.close();
}
if(myConn != null) {
myRs.close();
}
}
}
}
31 changes: 31 additions & 0 deletions DataBaseAccess1/src/main/java/ExampleUpdate/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ExampleUpdate;

import java.sql.*;

public class Main {
public static void main(String[] args) throws SQLException {
Connection myConn = null;
Statement myStm = null;
ResultSet myRs = null;

String dbURL = "";
String user = "root";
String pass = "root";

try {
myConn = DriverManager.getConnection(dbURL, user, pass);

myStm = myConn.createStatement();

System.out.println("Before update");

int rowsAffected = myStm.executeUpdate(
"update employee " +
"set email='johnExample@example.com' " +
"where last_name='exampleLastName' and first_name='exampleFirstName'");

} catch (Exception err) {
err.printStackTrace();
}
}
}
47 changes: 47 additions & 0 deletions DataBaseAccess1/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.example;

import java.sql.*;

/**
* Hello world!
*
*/
public class Main {
public static void main( String[] args ) throws SQLException {
// write your code here
Connection myConn = null;
Statement myStm = null;
ResultSet myRs = null;

try {
// Get a connection to database
myConn = DriverManager.getConnection("", "root", "root");

// Create a statement

myStm = myConn.createStatement();

// Execute SQL query
myRs = myStm.executeQuery("select * from x");

// Process the result set

while(myRs.next()) {
System.out.println(myRs.getString("examble_name") + ", " + myRs.getString("example_firstName"));
}
} catch (Exception err) {
err.printStackTrace();
}
finally {
if(myRs != null){
myRs.close();
}
if(myStm != null){
myStm.close();
}
}
}



}
20 changes: 20 additions & 0 deletions DataBaseAccess1/src/test/java/org/example/MainTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.example;

import org.junit.Test;

import static org.junit.Assert.assertTrue;

/**
* Unit test for simple App.
*/
public class MainTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
3 changes: 3 additions & 0 deletions DatabaseAccess/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions DatabaseAccess/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e6a91f6

Please sign in to comment.