from mysql to javascript -
i'm trying draw polyline coordinates mysql through javascript function within jsp file tried code below doesn't work!
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function initialisation(){ var centrecarte = new google.maps.latlng( 47.381381, 0.687503 ); var optionscarte = { zoom: 12, center: centrecarte, maptypeid: google.maps.maptypeid.roadmap } class.forname("com.mysql.jdbc.driver"); connection conn = null; statement state = null; resultset resul= null; conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/new","root","pass"); state=connection.createstatement(); string sql ="select lat, lng route "; result = statement.executequery(sql); while(result.next()){ s1= result.getfloat(lat); s2= result.getfloat(lng); var macarte = new google.maps.map( document.getelementbyid( "emplacementdemacarte" ), optionscarte ); var tableaupointspolyline = [ new google.maps.latlng("+s1+ ","+s2+") ]; var optionspolyline = { map: macarte, path: tableaupointspolyline }; var mapolyline = new google.maps.polyline( optionspolyline ); } google.maps.event.adddomlistener( window, 'load', initialisation ); } </script>
what needed fix problem listed?
stop trying random code! also, don't confuse java , javascript. code posted using scriptlets , missed <% %> symbols,
<% class.forname("com.mysql.jdbc.driver"); connection conn = null; statement state = null; resultset resul= null; // have mysql on localhost listening 3306. there new db? root's // password pass? conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/new","root","pass"); state=connection.createstatement(); string sql ="select lat, lng route "; result = statement.executequery(sql); while(result.next()){ %> s1=<%= result.getfloat(lat) %>; s2=<%= result.getfloat(lng) %>; <% } %>
note shouldn't using model 1 in 2014 (mixing java in general, jdbc code, in jsp asking trouble).
Comments
Post a Comment