Tag: java

How does the SQL Server JDBC Trusted Connection Authentication work?

How does the SQL Server JDBC Trusted Connection Authentication work? (ie how does the trusted connection authenticate the logged in AD user in such a transparent and elegant fashion and how can I implement a similar authentication solution for my client-server applications in Java without a database connection or any use of the existing SQL […]

Class Notfound exception in sqlserver connection in eclipse

My servlet function looks like these: CODE: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType(“text/html”); String userName; String passwd; Connection conn = null; userName = (String)request.getParameter(“userName”); passwd = (String)request.getParameter(“password”); try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); //Or any other driver } catch( Exception x ){ System.out.println( “Couldn’t load drivers!” ); } […]

The data types varchar(max) and text are incompatible in the equal to operator. in SQL Server2005 how to solve?

while(rs.next()) { String key=rs.getString(1); String val=rs.getString(2); it=ar1.get(k).toString(); if(it.trim().equals(key.trim())) { val=val.substring(1); val=val+”1″; } else { val=val.substring(1); val=val+”0″; } st = con.prepareStatement(“update win set seq=? where keyy=?”); st.setString(1,val); st.setString(2,key); //here i am getting exception st.executeUpdate(); st.close(); } if i change data type of seq and keyy in table as text then it shows The data types text […]

how to save image path to sql database in java

I have to save the image path chosen by jfilechooser to sql database and load that image every time from that sql path. Im using preparedStatment . But I got the path saved in sql database without “\” . Here is part my code.. Please help me on this. PreparedStatement ps = null; ResultSet rs […]

Cannot access SQL Server database using jtds

I am trying to access a SQL Server database using Java and jtds. This is my (very) simple code: String url = “jdbc:jtds:sqlserver://dev.company.com:1433/master;domain=COMP;USENTLMV2=true;SSL=request”; String driver = “net.sourceforge.jtds.jdbc.Driver”; String userName = “COMP\\username”; String password = “s3cr3t”; Connection conn = null; try { Class.forName(driver); conn = DriverManager.getConnection(url, userName, password); } catch (Exception e) { e.printStackTrace(); } finally […]

Hibernate Reverse Engineering Wizard – Available Tables Empty – issue

I’m trying to integrate Hibernate into my Netbeans project to connect to Microsoft SQL Server. I’ve run the Hibernate Configuration file wizard (and set up a new database connection). I’ve set the dialect to SqlServerDialect. I initially set up the connection with the db_owner schema. I’ve run test queries on the connection and they all […]

How to support support SqlServer's “..” in HyperSQL?

tl;dr: I am trying to unit test some SqlServer queries which state the db name but they do not seem to work in HyperSql. We are using Sql Server in production and I am trying to use HyperSQL as my database for unit testing. I am trying to test a class that creates SQL queries […]

“Repeated column in mapping for entity” where each column is only mapped once

I have a hibernate mapping file ParcelServicePresetIds.hbm.xml: <hibernate-mapping> <class name=”de.delife.sql.ParcelServicePresetIds” table=”ParcelServicePresetIDs” schema=”dbo” catalog=”xxx”> <id name=”id” type=”int”> <column name=”ID” /> <generator class=”assigned” /> </id> <many-to-one name=”itemsBase” class=”de.sql.ItemsBase” fetch=”select” property-ref=”itemId”> <column name=”ItemID” /> </many-to-one> <property name=”itemId” column=”ItemID” type=”java.lang.Integer”/> <property name=”intValue” type=”java.lang.Integer”> <column name=”intValue” /> </property> </class> </hibernate-mapping> When I run my program I get an error: Initial […]

Getting Checked Exception while running a SQL Program

import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.PrintWriter; import java.sql.*; import java.net.*; public class connection { JTextField textfeild; JButton button; String text; Socket sock; PrintWriter writer; JButton button1; public static void main(String[] args) { connection user1 = new connection(); user1.go(); }//main method close public void go() { JFrame frame12 = new JFrame(); JPanel centerpanel12 = […]

Running composite query on SQL server 2014 does not return result set

We have the following code: Connection conn = null; String dbURL = “jdbc:sqlserver://DBDerver details here”; String user = “user name”; String pass = “password@123”; try { Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); conn = DriverManager.getConnection(dbURL, user, pass); String sql = “update Table1” + “set DBID = DBID+1 where TABLENAME = ‘” + “Table2” + “‘;” + “select DBID from Table […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.