RE: [PHP] Re: How to connect to mysql through JAVA?

From: Date: Wed, 24 Apr 2002 15:24:09 +0000
Subject: RE: [PHP] Re: How to connect to mysql through JAVA?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94394@lists.php.net to get a copy of this message
Sourceforge MySQL JDBC driver http://mmmysql.sourceforge.net/ maybe this code frag will be helpful... String connectionURL = "jdbc:mysql://centauri.sbs:3306/dbname"; Connection conn = null; Statement statement = null; ResultSet rset = null; try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); conn = DriverManager.getConnection(connectionURL,"servlet","password"); statement = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rset = statement.executeQuery( "SELECT * FROM BROWSER WHERE sessionID='" + request.getParameter("session_id") +"'"); .. now use rset } // try catch( ClassNotFoundException e ) { PrintWriter pw = new PrintWriter(out, true); pw.println("Couldn't find the mm database driver: " + e.getMessage()); } catch( InstantiationException e ) { PrintWriter pw = new PrintWriter(out, true); pw.println(e.getMessage()); } catch( IllegalAccessException e ) { PrintWriter pw = new PrintWriter(out, true); pw.println(e.getMessage()); } catch( SQLException e ) { PrintWriter pw = new PrintWriter(out, true); pw.println("SQL Problem: " + e.getMessage()); pw.println("SQL State: " + e.getSQLState()); pw.println("Vendor Error: " + e.getErrorCode()); } finally { try { if ( conn != null ) conn.close(); } catch( SQLException e ) { PrintWriter pw = new PrintWriter(out, true); pw.println(e.getMessage()); } }

« previous php.general (#94394) next »