Dictionary:
import java.io.*;
import java.sql.*;
/**
*
*
@author Akhilesh
*/
public class NewDictionary {
public static void main(String args[]) throws SQLException,
ClassNotFoundException, IOException {
Connection con = prepareConnection();
Statement st = con.createStatement();
String query = "select * from [Sheet1$]";
ResultSet rs = st.executeQuery(query);
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.print("Enter Your Word Here:");
String i = br.readLine();
int count = 0;
System.out.println("Word\tMeaning:\n");
while (rs.next()) {
if (i.equals(rs.getString("word"))) {
System.out.println(i +
"\t" + rs.getString("meaning") + "\t\n");
count = 1;
}
}
if (count == 0) {
System.out.println("\nWord Does NOT matched in Dictionary\n");
}
}//main
public static Connection prepareConnection() throws SQLException,
ClassNotFoundException {
String driverClassName = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:mydsn";
Class.forName(driverClassName);
return DriverManager.getConnection(url);
}//prepareConnection
}//class
No comments:
Post a Comment