【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了TunnelParameters.java提供大家参考,希望对大家有所帮助!
package chimneydesign;
import java.sql.*;
import java.util.Vector;
import java.net.URL.*;
public class TunnelParameters
{
Connection con=null;
Vector tunnels;
public TunnelParameters()
{
tunnels = new Vector();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con =DriverManager.getConnection("jdbc:odbc:Tunnels");
Statement stmt = con.createStatement();
String
sqlStr = "select * from tunnels";
ResultSet rs = stmt.executeQuery(sqlStr);
while(rs.next())
{
double k = rs.getDouble("k");
double length = rs.getDouble("length");
double width = rs.getDouble("width");
double height = rs.getDouble("height");
double arcAngle = rs.getDouble("arcAngle");
double arcRadius = rs.getDouble("arcRadius");
double tStart = rs.getDouble("tStart");
double tDrop = rs.getDouble("tDrop");
double speed = rs.getDouble("speed");
ChimneyTunnel ct = new ChimneyTunnel(k,
length,
width,
height,
arcAngle,
arcRadius,
tStart,
tDrop,
speed);
tunnels.add(ct);
}
}
catch(Exception ex)
{
System.out.println("TunnelParameters.TunnelParamenters(): " + ex);
}
}
public static void main(String arg[])
{
TunnelParameters tp = new TunnelParameters();
int size = tp.tunnels.size();
for(int i=0; i<size; i++)
{
double width = ((ChimneyTunnel)tp.tunnels.elementAt(i)).width;
System.out.println("tunnel " + i + ": width=" + width);
}
}
}