Initial
This commit is contained in:
44
java/JDBCTest/jdbc.java
Normal file
44
java/JDBCTest/jdbc.java
Normal file
@@ -0,0 +1,44 @@
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
public class JDBC
|
||||
{
|
||||
public JDBC ()
|
||||
{
|
||||
}
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
String url="jdbc:odbc:Dive";
|
||||
Connection con;
|
||||
String query="select StockSymbol from Stocks";
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
|
||||
}
|
||||
catch(java.lang.ClassNotFoundException e)
|
||||
{
|
||||
System.err.print("ClassNotFoundException: ");
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
con=DriverManager.getConnection(url,"sa","");
|
||||
Statement stmt=con.createStatement();
|
||||
ResultSet rs = stmt.executeQuery(query);
|
||||
while (rs.next())
|
||||
{
|
||||
String s = rs.getString("StockSymbol");
|
||||
// float f = rs.getFloat("PRICE");
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
catch(java.sql.SQLException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user