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. if suppose i am having connection pool max size 30
View Tutorial By: Shrikant at 2012-07-20 12:09:33
2. I got the sample and the test working. Thanks a lo
View Tutorial By: Trishul at 2009-10-26 07:32:57
3. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial By: Sony at 2008-09-10 01:28:52
4. Your script works beautifully. Is there a way to i
View Tutorial By: JW at 2013-05-08 22:22:44
5. Nice basics. Very helpful
View Tutorial By: Gorav at 2011-11-11 12:46:28
6. sir every time we are using this.wedth(for example
View Tutorial By: praveen kumar at 2011-06-28 01:33:44
7. how to read a number from a keyboard and write tha
View Tutorial By: aiswarya at 2015-09-13 03:48:05
8. thank u sir ,this helped a lot
************
View Tutorial By: yugandharr at 2012-09-11 15:47:19
9. i am looking for the samples in java programming u
View Tutorial By: mary grace leron at 2010-02-18 01:50:50
10. Thanks. What datatype can we give to a variable St
View Tutorial By: Bafokeng Lebesa at 2012-11-27 12:35:40