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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. hie
can u plz tell how i maintain my rms f
View Tutorial By: diya at 2010-04-30 01:38:06
2. Dear sir,
Can you provide me for a simple p
View Tutorial By: kartikeya at 2012-12-22 10:19:41
3. Its really good and helpfull..........
chee
View Tutorial By: sumit at 2009-04-28 05:17:17
4. very useful example. Thanks for this help.
View Tutorial By: Saurabh at 2010-04-23 04:50:13
5. it is possible to write any synchronisation progra
View Tutorial By: shashi kant mishra at 2013-10-14 02:54:25
6. Nicely explained concept. Thankx.
View Tutorial By: Raghvendra at 2013-01-17 07:48:18
7. how to connect database simple method
View Tutorial By: kavimozhian at 2013-04-08 11:14:29
8. can you non grab the data direct from the vector w
View Tutorial By: paul at 2013-08-30 11:22:04
9. thanks, i will try. but can u tell me how to send
View Tutorial By: ketut joko wibawa at 2011-01-02 05:18:01
10. How to fix this Error.....
org.apac
View Tutorial By: james prabhakaran at 2014-12-02 13:08:30