package text
import java.sql.*
public class Fds {
public static void main(String[] args) throws SQLException {
Connection con = null
Statement st = null
ResultSet rs = null
String sql = "select names from systypes"
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
con = DriverManager.getConnection("jdbc:odbc:master", "sa",
"4217715")
st.execute(sql)
String t = null
while (rs.next()) {
t = rs.getString("name")
if (t != null) {
System.out.println("name:" + t)
}
if (t == null) {
System.out.println("no")
}
}
} catch (Exception e) {
} finally {
rs.close()
st.close()
con.close()
}
}
}
建立一个视图create or replace view test(isbn ,authorid ,name )as//这里字段自己写
select
a.isbn,
b.authorid,
decode(b.name ,null,’无作者‘,b.name)
from book a,author b,book_author c where a.isbn =c.isbn and c.authorid=b.authorid
之后
String sql="select * from test order by authorid"
ResultSet rs=dbconn.executeQuery(sql)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)