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. i can saved when i run the program...
but w

View Tutorial          By: kathleen ashley at 2010-08-02 05:22:46

2. Hi,
really nice article. but still have on

View Tutorial          By: Yogesh Rishipathak at 2009-06-04 02:25:06

3. sir, thanks sir. very help to me. its simple and e
View Tutorial          By: kannathasan.M at 2012-10-01 07:59:28

4. Hi,
I am getting this exception..My modem i

View Tutorial          By: divya at 2008-04-27 04:12:19

5. very very useful..thank you
View Tutorial          By: sridaran at 2009-03-21 00:45:21

6. so good .to give easy understand
View Tutorial          By: ashok .my no 9618738732 at 2010-02-15 06:19:48

7. How can I use stack in entering a letter and will
View Tutorial          By: mards at 2014-10-17 12:18:34

8. I don't undrstnd.. cz I think in recurs the method
View Tutorial          By: Alina Ali at 2014-11-13 03:06:17

9. i got error for below line

xlApp

View Tutorial          By: Satheyaraaj at 2015-04-28 07:47:42

10. You just save ma arse, had a SQLite database, and
View Tutorial          By: codeRealm at 2011-11-13 12:58:05