<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<title>populatong a postgis via Javaappl.</title>
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:#606420;
text-decoration:underline;}
p
{mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman";}
span.EmailStyle18
{mso-style-type:personal;
font-family:Arial;
color:navy;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink="#606420">
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I would like to insert a point in a postgis
database.<o:p></o:p></span></font></p>
<p><font size=2 color=fuchsia face=Arial><span style='font-size:10.0pt;
font-family:Arial;color:fuchsia'>BEGIN;<br>
INSERT INTO "public"."ais" ("mmsi", the_geom) <br>
VALUES ('123', ,GeometryFromText('POINT(-73.910977172366
40.729270630126)',-1));<br>
END;<o:p></o:p></span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>This
is what I have tried in java.<o:p></o:p></span></font></p>
<p><font size=2 color="#339966" face=Arial><span style='font-size:10.0pt;
font-family:Arial;color:#339966'>static private Connection con = null;<br>
double lat 63.049813568477724;<br>
double lon 20.26472335111486;<br>
<br>
Class.forName(org.postgresql.Driver);<br>
con = DriverManager.getConnection(“jdbc:postgresql:postgis”, “username”,
“pw”);<br>
PreparedStatement stmt = con.prepareStatement("insert into ais (mmsi,
the_geom) " + "values(?, ?)");<br>
stmt.setString(1, “abc”);<br>
stmt.setString(2, "GeometryFromText('POINT(" + lat + " " +
lon + ")',-1)");<br>
System.out.println(stmt);<br>
stmt.executeUpdate();<o:p></o:p></span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>This
is what</span></font> <font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>System.out.println prints:<br>
<font color="#3366ff"><span style='color:#3366FF'>insert into ais (mmsi, the_geom)
values(abc, GeometryFromText('POINT(63.049813568477724 20.26472335111486)',-1))</span></font></span></font><font
color="#3366ff"><span style='color:#3366FF'><o:p></o:p></span></font></p>
<p><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>This
is the Error message<br>
<font color=red><span style='color:red'>org.postgresql.util.PSQLException:
ERROR: column "the_geom" is of type geometry but expression is of
type character varying</span></font></span></font><font color=red><span
style='color:red'><o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Could someone please tell me where I can
read about how to do this, or if someone could send me a little example? I have
not found any documentation that shows this (at least as far as I understand I’m
new at both Java and SQL).<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This must be a basic thing, but I don’t
get it…<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks..<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> <o:p></o:p></span></font></p>
</div>
</body>
</html>
<HTML><BODY><P><hr size=1></P><br>
<P><STRONG><br>
The substance of this message, including any attachments, may be<br>
confidential, legally privileged and/or exempt from disclosure<br>
pursuant to Massachusetts law. It is intended solely for the<br>
addressee. If you received this in error, please contact the sender<br>
and delete the material from any computer.<br>
</STRONG></P></BODY>