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. when i copy paste your program or source code

View Tutorial          By: hello at 2010-07-09 18:56:23

2. God bless u man! :)
View Tutorial          By: me at 2015-07-29 13:25:00

3. I can't get it untill now. I need further explaina
View Tutorial          By: johnlie at 2011-01-19 20:31:09

4. Good information...it help me to do mi projecto! t
View Tutorial          By: gnk at 2010-08-12 01:01:50

5. Unable to understand all the points, quiet confusi
View Tutorial          By: KB at 2015-04-15 10:11:14

6. Thank you sir this is a nice example/
View Tutorial          By: Techbymak at 2013-01-08 09:51:54

7. i am trying to create a handy and powerful barcode
View Tutorial          By: incoming barcode scanner at 2014-06-23 04:23:42

8. Thank you!!!

just to make things c

View Tutorial          By: Oscar Torres at 2015-02-19 14:25:05

9. wehhh... so so so difficult
View Tutorial          By: sam at 2013-02-28 01:55:41

10. super explanation
View Tutorial          By: pree at 2013-12-30 16:41:32