watt Posted October 24, 2007 at 11:55 AM Report Share #142616 Posted October 24, 2007 at 11:55 AM Boas ppl! estou a fazer um programa com o netbeans, e estou a a usar jframes, e o que eu gostava de sabes é como é que abro um jframe dentro de outro. para que só tenha uma janela no desktop, e dentro dessa janela aparecem as outras janelas do programa... alguém sabe como se faz isto ? Link to comment Share on other sites More sharing options...
rgcaldas Posted October 24, 2007 at 02:09 PM Report Share #142644 Posted October 24, 2007 at 02:09 PM Pelo que sei tens de utilizar MDI aqui fica um link http://www.developerfusion.co.uk/show/3798/5/ espero que ajude Link to comment Share on other sites More sharing options...
watt Posted November 7, 2007 at 05:25 PM Author Report Share #145943 Posted November 7, 2007 at 05:25 PM Boas! estou a tentar ligar ao meu projecto uma bd em access, e estou com um erro que n estou a perceber... o código que tenho é o seguinte. Class bd está no file bd.java. package gestor; import java.sql.*; public class bd { public static Connection getConnection() throws Exception { Driver d = (Driver)Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); Connection c = DriverManager.getConnection( "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/dados.mdb" ); return c; } public void teste(){ System.out.println("teste"); } } Aparente-mente aqui está td ok, não dá erros. depois tenho o ficheiro princincipal e aqui dentro estou a mexer no private void Frame1InternalFrameActivated que dá erro, e o condigo q tenho é o seguinte. static Connection Conn; private void Frame1InternalFrameActivated(javax.swing.event.InternalFrameEvent evt) { // TODO add your handling code here: Conn = lig.getConnection(); <- Erro - D:\escola\POO\Gestor\src\Principal.java:221: unreported exception java.lang.Exception; must be caught or declared to be thrown ResultSet rs; Statement stmt; String sql; sql = "select * from Artigos"; stmt = Conn.createStatement(); rs = stmt.executeQuery(sql); jLabel6.setText(""); } será que alguém me pode dar uma ajuda ?! Link to comment Share on other sites More sharing options...
freesumo Posted November 7, 2007 at 10:56 PM Report Share #146026 Posted November 7, 2007 at 10:56 PM (...)must be caught or declared to be thrown(...) Você tem public static Connection getConnection() throws Exception {... por isso quando chama o método ou faz: /* declared to be thrown */ private void Frame1InternalFrameActivated(javax.swing.event.InternalFrameEvent evt) throws Exception { . . . Ou então ponha o código dentro de um try-catch: private void Frame1InternalFrameActivated(javax.swing.event.InternalFrameEvent evt){ /* must be caught */ try{ Conn = lig.getConnection(); String sql = "select * from Artigos"; Statement stmt = Conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); jLabel6.setText(""); }catch(Exception e){ //Exception handling... }; . . . JDBC Cumprimentos 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now