importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.Statement;publicclassshiyan4{publicstaticfinalStringDBDRIVER="org.gjt.mm.mysql.Driver";publicstaticfinalStringDBURL="jdbc:mysql://localhost:3306/ace";publicstaticfinalStringDBUSER="root";publicstaticfinalStringDBPASS="root";publicstaticvoidmain(Stringargs[])throwsException{Connectionconn=null;Statementstmt=null;Class.forName(DBDRIVER);Stringsql="SELECTuser_nameFROMusers;";conn=DriverManager.getConnection(DBURL,DBUSER,DBPASS);stmt=conn.createStatement();stmt.executeUpdate(sql);stmt.close();conn.close();}}请问这样怎么修改才能正常的进行查询和在java上输出查询到的信息
相关分类