Listing Códb.jsp


<%@ page language="java" %><%response.setContentType("x-world/x-vrml");%>#VRML V2.0 utf8

Viewpoint

{

       position      10 0 50

       orientation   1 0 0 -0.1

       description   "Entry"

}

<%

       //Connection strings

       String driver        = "oracle.jdbc.driver.OracleDriver";

       String dburl  = "jdbc:oracle:thin:@faustus:1521:intra";

       String dbuid = "spheres";

       String dbpwd = "spheres";

       //Define sphere variables

       String color = "";

       String radius = "";

       //Variables:

       String sql = "SELECT * FROM spheres";

       int id = 0;

       try {

       //Get ResultSet

       Class.forName(driver);

       Connection con = DriverManager.getConnection(dburl, dbuid, dbpwd);

       Statement stmt = con.createStatement();

       ResultSet rs = stmt.executeQuery(sql);

       int count = 0;

       while(rs.next())

       {

              color = rs.getString("color");

              radius = rs.getString("radius");

%>

              DEF sphere<%=count%> Transform

              {

                     translation <%=count*10%> 0 0


                     children

                     [

                           Shape

                           {

                                  appearance Appearance

                                  {

                                         material Material

                                         {

                                                diffuseColor <%=color%>

                                         }

                                  }

 
 
                                  geometry Sphere

                                  {

                                         radius <%=radius%>

                                  }

                           }

                     ]

              }

<%

       count++;

       }

              stmt.close();

              con.close();

       }catch (java.lang.Exception ex){out.print(ex.toString());}

%>