jdbc桥接odbc 访问access数据库出现"参数不足,期待是1"?
importjava.sql.*;publicclasssearch_flight{publicstaticvoidmain(Stringargs[]){Connecti...
import java.sql.*;
public class search_flight
{
public static void main(String args[])
{
Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("trip.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try
{
con = DriverManager.getConnection("jdbc:odbc:trip","","");
sql = con.createStatement();
rs = sql.executeQuery("SELECT flightNum,FromCity,ArivCity,flightprice FROM FLIGHTS WHERE flight_numAvail>0");
while(rs.next())
{
String flightNum = rs.getString(1);
String FromCity = rs.getString(2);
String ArivCity = rs.getString(3);
int flightprice = rs.getInt(4);
}
con.close();
}
catch(SQLException e)
{
System.out.println(e);
}
}
}
运行时出现:
java.sql.SQLException:[Microsoft][ODBC Microsoft Access Driver]参数不足,期待是1
请问是sql语句有问题么? 展开
public class search_flight
{
public static void main(String args[])
{
Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("trip.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try
{
con = DriverManager.getConnection("jdbc:odbc:trip","","");
sql = con.createStatement();
rs = sql.executeQuery("SELECT flightNum,FromCity,ArivCity,flightprice FROM FLIGHTS WHERE flight_numAvail>0");
while(rs.next())
{
String flightNum = rs.getString(1);
String FromCity = rs.getString(2);
String ArivCity = rs.getString(3);
int flightprice = rs.getInt(4);
}
con.close();
}
catch(SQLException e)
{
System.out.println(e);
}
}
}
运行时出现:
java.sql.SQLException:[Microsoft][ODBC Microsoft Access Driver]参数不足,期待是1
请问是sql语句有问题么? 展开
展开全部
con = DriverManager.getConnection("jdbc:odbc:trip","","");
参数不足,说的是这一句,对照改一下把。
参数不足,说的是这一句,对照改一下把。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
rs.close();
sql.close();
con.close();
sql.close();
con.close();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
出现这样的问题极有可能是查询语句的属性名写错了,仔细检查一下.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询