Owen Martin

Greenhorn
+ Follow
since Mar 05, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Owen Martin

Hi, I am sending mails via Java Mail. I want to relay information to people but depending on the circumstance the text and the amount of paragraphs will change.

How do I dynamically add plain text to a Java Mail?

12 years ago
I have one more question didn't think it was worth a thread.

Say I execute an update statement to insert a new row into a table, I immediately need to use the generated id of that row. How do I retrieve it seen as an update doesn't produce a result set?
It was due to not having the column as varbinary(max) apparently. Thanks.
I have got closer, but it does not seem to work.



Any help? Much needed!

The column is of type binary(50) where the stream is supposed to go.
Its a SQL database. Using SQL Server.

Thanks will give it a try. Why does it only work with a prepared statement, do you have an example?
Hi there. I have a Java program which allows the user to select a File from there desktop.

I then want to save this in my database, where I have a column which is of type IMAGE.

My query is "INSERT INTO MYTABLE VALUES(199,'This is a file' , " + getByteArray(files.get(0)) + ")";

This does not work, is their a better way to do it?
Get a incorrect syntax error when trying to use to_date, I am using SQL Server and SQL Server Management Studio
Hi there, I am using JDBC and a SQL database.

I have an alarm field in the database which is of date/time.

On my front end I have a String of the format, '01-05-2012' and I am simply inserting it into the database by using the INSERT into X Values ('01-05-2012)

Is this the right way to go about storing a date? Do I need to declare anything the database?
I couldn't find out which port it was using so I manually set it to 1433 and thats that sorted.

Butt...I use Windows User Authentication, how do I use that in the connection string?
Thanks for your reply that has helped.

However I am not getting this error, but I have went into the Configuration Manager and set TCP/IP to be enabled and disabled the firewall;

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1033)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DatabaseConnect.main(DatabaseConnect.java:20)

That is after using the connection String;



?

Hi there, I am a beginner but am currently trying to connect a SQL database I have made in SSMSE using SQL Server 2005 with my Java front end in the Eclipse IDE.

Firstly I see many tutorials for mySQl using JDBC but not SQL, is there a reason for this or are they much of the same?

I started off by downloading the driver, which I thought was the right one; http://www.microsoft.com/download/en/details.aspx?id=21599

And to test it I wrote the following code;



This gives me an exception("com.sql.jdbc.Driver")

I think I might have the driver name wrong, but what specifically should it be called as its just a .jar file called sqljdbc4

Thanks?
Hey guys, I am just trying out 'simple' Java techniques for practise and I am already stuck.

Don't worry about the code itself in terms of efficiency etc, I just want to know why this doesn't work.

I know I can change the 'add' method to static but I done that in a previous program and nearly all my methods were made static and running it etc started to confuse me.

I have one class, and a test class.




13 years ago
Feel so stupid now, thanks very much that has been hassling me for a good while. Cheers.
14 years ago
Hi, I have an empty Tree(t) which is passed into my method, along with a String(s). I then check if the root (t.data) is empty, which it is. I then set the t.data to equal the String passed in. I have initialized my Tree so it can be empty, or a Tree can contain a String at the root and null either side.

But when I try and return I get this error code

Nameofpackage.Tree@e48e1b



Any ideas?
14 years ago