create issue via plugin

hi,

i need to developpe a plugin that can import data from my table exesting in my database and present very row in this table as an issue please i need your help

4 answers

This widget could not be displayed.

That's quite a vagues question, you don't really tell us where you are stuck.

However, I'd look at the Jira importers - some of them can read data direct from a database and import the lines as issues.

In first, thinks for your answer, this is what i really need read data direcr from a database and import the lines as issues, i didn't find a tutorial or an answer for this question, please Nic if you have something to help please give it to me, think you, i forget i have a mysql table and each row i want present it as an issue

I'm not sure we can tell you a lot more.

You have a database table with issues in it - you need to convert that to a format Jira can read, and then you need to import it into Jira (then probably throw the database table away, as you've migrated it to Jira and don't need it any more)

Jira has some importers which can help you with it. The most simple approach really is to run simple SQL to get the data into a CSV format and import that.

This widget could not be displayed.

Hi Asmaa,

You have to write your own migrator for it or you should use some tricks like below

Database to >> CSV and CSV to >> JIRA's CSV importer and map the fields and import.

below Java code will convert table data to csv file.

Cheers

Onkar Ahire

public static void main(String[] args) {
          
          //usual database connection part
          Connection con = null;
          String url = "jdbc:mysql://localhost:3306/";
          String db = "db_name";
          String driver = "com.mysql.jdbc.Driver";
          String user = "username";
          String pass = "password";
          FileWriter fw ;
          try{
          Class.forName(driver);
          con = DriverManager.getConnection(url+db, user, pass);
          Statement st = con.createStatement();
           
          //this query gets all the tables in your database(put your db name in the query)
          ResultSet res = st.executeQuery("SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'db_name' ");
           
          //Preparing List of table Names
          List <String> tableNameList = new ArrayList<String>();
          while(res.next())
          {
              tableNameList.add(res.getString(1));
          }
           
          //path to the folder where you will save your csv files
          String filename = "D:/db2csv/";
           
          //star iterating on each table to fetch its data and save in a .csv file
          for(String tableName:tableNameList)
            {
                int k=0;
                 
                int j=1;
                 
                System.out.println(tableName);
                 
                List<String> columnsNameList  = new ArrayList<String>();
                 
                //select all data from table
                res = st.executeQuery("select * from xcms."+tableName);
                 
                //colunm count is necessay as the tables are dynamic and we need to figure out the numbers of columns
                int colunmCount = getColumnCount(res);
                 
                 try {
                    fw = new FileWriter(filename+""+tableName+".csv");
                     
                     
                    //this loop is used to add column names at the top of file , if you do not need it just comment this loop
                    for(int i=1 ; i<= colunmCount ;i++)
                    {
                        fw.append(res.getMetaData().getColumnName(i));
                        fw.append(",");
             
                    }
                     
                    fw.append(System.getProperty("line.separator"));
                     
                    while(res.next())
                    {
                        for(int i=1;i<=colunmCount;i++)
                        {
                             
                            //you can update it here by using the column type but i am fine with the data so just converting 
                            //everything to string first and then saving
                            if(res.getObject(i)!=null)
                            {
                            String data= res.getObject(i).toString();
                            fw.append(data) ;
                            fw.append(",");
                            }
                            else
                            {
                                String data= "null";
                                fw.append(data) ;
                                fw.append(",");
                            }
                             
                        }
                        //new line entered after each row
                        fw.append(System.getProperty("line.separator"));
                    }
                     
                     fw.flush();
                      fw.close();
                     
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                 
            }
                 
          con.close();
          }
          catch (ClassNotFoundException e){
          System.err.println("Could not load JDBC driver");
          e.printStackTrace();
          }
          catch(SQLException ex){
          System.err.println("SQLException information");
          }
 }
     
    //to get numbers of rows in a result set 
    public static int  getRowCount(ResultSet res) throws SQLException
    {
          res.last();
          int numberOfRows = res.getRow();
          res.beforeFirst();
          return numberOfRows;
    }
 
    //to get no of columns in result set
     
    public static int  getColumnCount(ResultSet res) throws SQLException
    {
        return res.getMetaData().getColumnCount();
    }

Hi Onkar, think you very very much for your help, you i didn't know that there is a difference between a simple csv and jira csv importer, i have two question in this point: 1-actually i have an evaluation version of jira i found a problem in the step Map fields i can't move to the next step, the second question the csv field can got a lot of lignes and each ligne associate them to an issue jira , think you again Onkar

This widget could not be displayed.

Hi Asmaa,

With the help from External System Import in JIRA the below link is useful for you.

https://confluence.atlassian.com/display/JIRA/Importing+Data+from+CSV

Cheers

Onkar Ahire

This widget could not be displayed.

Think's Onkar, i have an other request please do you have any idea about using API like create jira issue in a programme externe developping in eclipse??

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

223 views 3 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you