1 / 12

A tutorial on CSE305 project

A tutorial on CSE305 project. Bin Tang (Bin Tang@cs.sunysb.edu). Outline. Work from home Jbuilder Sybase and JDBC. Jisql. How to connect Sybase using JDBC. How to integrate into your Jbuilder…. Work from Home. SSH2 client upload the files to the transaction lab file server

quon-barnes
Download Presentation

A tutorial on CSE305 project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A tutorial on CSE305 project Bin Tang (Bin Tang@cs.sunysb.edu)

  2. Outline • Work from home • Jbuilder • Sybase and JDBC. • Jisql. • How to connect Sybase using JDBC. • How to integrate into your Jbuilder…

  3. Work from Home • SSH2 client • upload the files to the transaction lab file server • Copy /com(which contains the JDBC driver) to your home machine and set up (see hint page for details) • Interact with Sybase • Using the gateway applet located at http://www.translab.cs.sunysb.edu/demo/gateway.html

  4. How to connect to Sybase using JDBC • http://www.translab.cs.sunysb.edu/demo/menu.java • JDBCDriver = "com.sybase.jdbc.SybDriver"; URL="jdbc:sybase:Tds:sbntdbm.translab.cs.sunysb.edu:5000"; Proxy = "www.translab.cs.sunysb.edu:8000"; String UserID = ”cse305_ta"; String Password = ”abcdefg"; • prop = new Properties(); prop.put("user", UserID); prop.put("password", Password); prop.put("proxy", Proxy);

  5. JDBC Organization Driver1 Driver Manager Application Driver2 DBMS Driver3

  6. How to connect to Sybase using JDBC • Load JDBC Driver and register it to DriverManager Class c =Class.forName("com.sybase.jdbc.SybDriver"); DriverManager.registerDriver((Driver) c.newInstance()); • Connect to Sybase Con = DriverManager.getConnection(URL, prop); • Create a statement object from the connection object(in doSelect()/doSelect2() ). Statement stmtSelect = Con.createStatement(); • Execute the statement object. • ResultSet result = stmtSelect.executeQuery(sSelectStmt); • doSelect(String sSelectStmt, int cols) -- Select • int row_affected = stmtSelect.executeUpdate(sSelectStmt); • doSelect2(String sSelectStmt, int cols) –Update, Insert

  7. Get the result back Statement stmt = mycncCon.createStatement(); ResultSet result = stmt.executeQuery("SELECT Name, Adress FROM Users WHERE Fine > 5.00“, 2); while(result.next()) { jName.setText(result.getString(1)); jAdress.setText(result.getString(2)); }

More Related