Comment on Tutorial - A simple JDBC application sample code By Ramlak



Comment Added by : ali

Comment Added at : 2013-08-12 07:56:01

Comment on Tutorial : A simple JDBC application sample code By Ramlak
this code runs permanently!!! created by diko(Turkey)

public void mysql() {

try {
Class.forName(“com.mysql.jdbc.Driver”);
} catch (ClassNotFoundException e) {
e.printStackTrace();

}

thrd1 = new Thread(new Runnable() {
public void run() {
while (!Thread.interrupted()) {
try {
Thread.sleep(100);
} catch (InterruptedException e1) {

}
if (con == null) {
try {
con = DriverManager.getConnection(“jdbc:mysql://192.168.1.45:3306/deneme”, “ali”, “12345″);

} catch (SQLException e) {
e.printStackTrace();
con = null;
}

if ((thrd2 != null) && (!thrd2.isAlive()))
thrd2.start();

}
}

}
});
if ((thrd1 != null) && (!thrd1.isAlive())) thrd1.start();

thrd2 = new Thread(new Runnable() {
public void run() {
while (!Thread.interrupted()) {

if (con != null) {
try {
// con = DriverManager.getConnection(“jdbc:mysql://192.168.1.45:3306/deneme”, “ali”, “12345″);
Statement st = con.createStatement();
String ali = “‘fff’”;
st.execute(“INSERT INTO deneme (name) VALUES(” + ali + “)”);
// ResultSet rs = st.executeQuery(“select * from deneme”);
// ResultSetMetaData rsmd = rs.getMetaData();
// String result = new String();

// while (rs.next()) {
// result += rsmd.getColumnName(1) + “: ” + rs.getInt(1) + “\n”;
// result += rsmd.getColumnName(2) + “: ” + rs.getString(2) + “\n”;

// }

} catch (SQLException e) {
e.printStackTrace();
con = null;
}

try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

});

}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Very nice to understand the concept.It also help t
View Tutorial          By: Hrusikesh jena at 2011-05-26 00:23:28

2. Hi, you put a semicolon after "int main()&quo
View Tutorial          By: noel4037 at 2009-12-28 06:40:17

3. i want complete notes on java from basics
View Tutorial          By: spandana at 2010-02-12 04:44:13

4. plz can you help me,,,because i need this tomorrow
View Tutorial          By: ivie at 2012-12-12 11:20:35

5. Excelent article, I will start to use struts 2 now
View Tutorial          By: Alex at 2010-01-20 16:13:34

6. How do u edit the text ? this is always replacing
View Tutorial          By: anurag at 2012-08-23 07:24:47

7. Thanks dude its really helpful. it clears my doubt
View Tutorial          By: Sriram at 2009-12-28 05:54:37

8. very good exmpl and explantion
View Tutorial          By: harshita negi at 2013-10-16 02:19:35

9. Great Thanks
View Tutorial          By: seedimani at 2009-09-16 01:27:26

10. Turning off hostname checking also turns off all s
View Tutorial          By: eric at 2014-01-30 18:09:05