JAVA数据库连接小程序错误

JAVA数据库连接小程序错误,第1张

能缩进一下不?

你while括号应该把if括起来才对

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)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9926551.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-03
下一篇 2023-05-03

发表评论

登录后才能评论

评论列表(0条)

保存