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. hi.I am new in j2me and really want to learn more
View Tutorial          By: Vicky Mittal at 2012-01-05 11:45:53

2. Just what I was looking for. Great work. thx.
View Tutorial          By: SP Goh at 2008-03-24 01:09:09

3. i have a error while i running this program

View Tutorial          By: parul at 2012-02-08 15:40:09

4. The one more best way is

public cl

View Tutorial          By: Palla Subramanyam at 2012-01-25 20:18:03

5. nice ....Simple undersstanding..
View Tutorial          By: Anjaneyulu at 2013-06-15 04:43:45

6. Hi there is two ways you can get information.

View Tutorial          By: Sathyam at 2008-12-15 02:01:22

7. This works with inserts but it is very slow for lo
View Tutorial          By: Antonio Pereira at 2011-02-04 08:54:45

8. I really not get your points...
I don't kno

View Tutorial          By: darshit jain at 2014-05-22 09:07:45

9. worked for me thanks.
View Tutorial          By: dem125 at 2010-08-03 23:30:32

10. really this introduction makes me very interesting
View Tutorial          By: Himaja Reddy at 2012-11-09 06:57:31