Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting details into sql server?

Nageswarara Rao
Contributor
May 5, 2013

Hi i have a requirement to insert values into sql server table in my jira plugin , i created a new table with three columns , i wrote the following code to insert values into database table , but the values are not inserting , following is my code snipet

namevalue = getName();
        desvalue = getDescription();
        roleValue = getRole();

   Class.forName("net.sourceforge.jtds.jdbc.Driver" );
          
            Connection con =DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/jiradb","jirauser","jirauser");
            log.info("test connection..");
            String query = "insert into jiradb.dbo.testworklog values(namevalue,desvalue,rolevalue)";
            Statement stmt = con.createStatement();
            stmt.executeQuery(query);
            log.info("values inserted in database table.. ");
            con.close();

Can any body guide me where i did the mistake .

Thanks in advance

1 answer

0 votes
Peter Van de Voorde
Community Champion
May 5, 2013

You should use your variables in the query string, like this :

String query = "insert into jiradb.dbo.testworklog values("+namevalue+","+desvalue+","+rolevalue+")";

Best regards

Peter

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events