-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> |
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(); | ||
} | ||
} | ||
} | ||
} |
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(); | ||
} | ||
} | ||
} |
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(); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
} |
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 ); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.