searching in database using java
import java.sql.*;
public class jdbcConn {
public static void main(String[] args) throws Exception {
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection(
"jdbc:derby://localhost:1527/testDb","username", "password");
Statement stmt = con.createStatement();
String query[] = {
"SELECT * FROM emp where id = 1",
"select name from emp where name like 'ravi_'",
"select name from emp where name like 'ravi%'"
};
for(String q : query) {
ResultSet rs = stmt.executeQuery(q);
System.out.println("Names for query "+q+" are");
while (rs.next()) {
String name = rs.getString("name");
System.out.print(name+" ");
}
System.out.println();
}
}
}
Also in Java:
- how to create a subclass in java
- hashmaps java
- java list as parameter
- binary to int java
- how to reverse a string in java
- java hashmap put
- java lambda list of objects cast
- java execute jar from main
- binary search java
- android java add new record to Firebase Firestore
- 2 decimal places print format JAVA
- java code to concatinate integer
- check if value exists in hashset java
- how to read file from assets folder in android
- bracket balancing program in java
- get raondom from array java
- check if string is decimal java
- Write a method that raises a number to a power without using Math.pow() method
- java file path linux
- java output length of each line in a text document
- jbutton close jframe java
- Java use Base64
- java builder pattern example
- Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']